Webhook support, misc fixes

* Added support for slack (mattermost) webhooks
* Misc fixes
This commit is contained in:
2022-03-08 01:04:03 +01:00
parent 6cdb155dc5
commit 1f44d9f44b
5 changed files with 53 additions and 11 deletions

View File

@ -0,0 +1,13 @@
<?php
namespace NoccyLabs\FreshDocker\Hooks;
use GuzzleHttp\Client;
use RuntimeException;
interface HookInterface
{
public function sendMessage(string $text, array $options);
}

View File

@ -5,7 +5,7 @@ namespace NoccyLabs\FreshDocker\Hooks;
use GuzzleHttp\Client;
use RuntimeException;
class SlackHook
class SlackHook implements HookInterface
{
private array $options = [];
@ -49,6 +49,10 @@ class SlackHook
if (array_key_exists('channel', $options)) $body['channel'] = $options['channel'];
if (array_key_exists('username', $options)) $body['username'] = $options['username'];
if (array_key_exists('icon_url', $options)) $body['icon_url'] = $options['icon_url'];
if (array_key_exists('info', $options)) {
if (!array_key_exists('props', $body)) $body['props'] = [];
$body['props']['card'] = $options['info'];
}
$body['text'] = $text;
return $body;