-
Notifications
You must be signed in to change notification settings - Fork 1
Notification Channels
Please review and understand that the major lift with adding additional notification channels is already done with the NotificationStrategy class.
There are two required fields per channel that need to be added to the channels
array in the config file.
- enabled
- Default this to
false
- Default this to
- hook
- ensure this is pulling from the
env('CHANNEL_HOOK')
.
- ensure this is pulling from the
Take a gander at the Discord Channel Notification
Create your new channel class in the YorCreative/Laravel-Query-Watcher/Strategies/NotificationStrategy/Channels
namespace.
The new channel class needs to implement the NotificationChannelInterface.
You will need to pull the enabled field from the configuration file as shown.
/**
* @return bool
*/
public function isEnabled(): bool
{
return config('querywatcher.channels.NEW_CHANNEL.enabled');
}
Put your logic into the notify method as shown.
/**
* @param QueryModel $model
*/
public function notify(QueryModel $model): void
{
// Build out your Web-hook payload using information in the QueryModel
// Fire off a POST with Http::post()
}
Auto discovery is planned but till that gets implemented, you will need to add the new Notification Channel to the getChannels
Collection in the Channel Service
/**
* @return Collection
*/
protected static function getChannels(): Collection
{
return new Collection([
new Discord(),
new Slack()
]);
}
The NotificationStrategy will handle the rest.
Please ensure you add at the very least basic test coverage using the current test coverage as an example.
Update the readme to reflect the new notification channel. Please include an article on how to retrieve the web-hook for the new notification channel.