Webhook support, misc fixes
* Added support for slack (mattermost) webhooks * Misc fixes
This commit is contained in:
13
src/Hooks/HookInterface.php
Normal file
13
src/Hooks/HookInterface.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace NoccyLabs\FreshDocker\Hooks;
|
||||
|
||||
use GuzzleHttp\Client;
|
||||
use RuntimeException;
|
||||
|
||||
interface HookInterface
|
||||
{
|
||||
|
||||
public function sendMessage(string $text, array $options);
|
||||
|
||||
}
|
@ -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;
|
||||
|
Reference in New Issue
Block a user