Download the PHP package herpaderpaldent/seat-notifications without Composer
On this page you can find all versions of the php package herpaderpaldent/seat-notifications. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download herpaderpaldent/seat-notifications
More information about herpaderpaldent/seat-notifications
Files in herpaderpaldent/seat-notifications
Package seat-notifications
Short Description With this SeAT Package you can setup and manage notifications. It is build to be expendend from within the package or from another package
License MIT
Informations about the package seat-notifications
seat-notifications
With this SeAT Package you can setup and manage notifications. It is build to be expended from within the package or from another package. Please read more about it further down.
Important: seat-notifications are work in progress and certainly have some bugs please do report any findings to seat-slack and report it as an issue.
Installation
- cd to
/var/www/seat
- enter
composer require herpaderpaldent/seat-notifications
- run migration
php artisan migrate
Enable Notification Channel
To enable seat-notifications
functionality of sending notifications. Create a bot for your notification channel. By default seat-notifications offers two notification channels which could be extended by other packages: slack
and discord
:
a more detailed guide on oAuth creation will follow for now the blow table must suffice:
Notification Channel | Redirect URLs | Comment |
---|---|---|
Discord | {seat_url}/seatnotifications/discord/configuration/callback/server | This callback url is needed for the configuration of your discord bot. |
Discord | {seat_url}/seatnotifications/discord/callback/user | This callback url is needed for the authentication of a discord user. |
Slack | {seat_url}/seatnotifications/slack/configuration/callback/server | This callback url is needed for the configuration of your slack bot. |
Slack | {seat_url}/seatnotifications/slack/callback/user | This callback url is needed for the authentication of a slack user. |
Note: you may only configure one notification channel at your will. However, for discord you must create a bot in your application. For Slack you need to add the bot permission to your oauth scope.
Setup Roles
To be able to subscribe to a notification the user needs the appropriate permission. Please setup a role that carries the needed permission and assign it to users that should be able to receive the notification.
Restart workers
Since the notifications are send out by your workers you need to restart them to pick up the new code. Do this either via docker-compose restart seat-worker
if you use docker, or supervisorctl restart worker
on linux distributions.
Authenticate
Users need to authenticate for your setup notification channel prior to receiving notifications. they may do this in the registration box on the notification page.
What does the package do at the moment
- Send
RefreshTokenDeleted
Notification to Discord and/or Slack when arefresh_token
is deleted. - Using Model Observer to dispatch Notifications
- Notifications are queueable and send out via the queue.
- The RefreshTokenNotification is able to be delivered to Channels or via DM on the users preference.
Example:
Developing
Most importantly: take note of laravel's notification documentation. Secondly have a look at this package service provider as it helps with merging the services array properly. The provided example of RefreshTokenDeletedNotification is based upon it. Notifications are being send by using the Notification
facade:
where $receipients
are a collection of modal that should receive the notification and $refresh_token
is the deleted refresh_token
that is passed to the constructor. In this example we use an Observer to send notifications: Observer.
Architecture
Add new drivers
If you have written a new notification driver that you would like to use for sending notifications to your users you might extend config/services.php
similar to the provided example:
Your driver should extend Herpaderpaldent\Seat\SeatNotifications\Drivers\AbstractNotificationDriver
and should contain;
Add new notifications
If you want to extend the available notifications you need to extend the seat-notification
array in config/services.php
:
Your abstract notification must extend Herpaderpaldent\Seat\SeatNotifications\Notifications\AbstractNotification
and contain the following methods to add your notification to the users notification list:
Use Notification Dispatcher
In order to dispatch notification solely to receiver that subscribed to the notification it is advised to use a custom dispatcher job f.e.:
``
All versions of seat-notifications with dependencies
laravel/framework Version 5.5.*
eveseat/web Version ~3.0.15
erusev/parsedown Version ^1.7
textalk/websocket Version 1.0.*
restcord/restcord Version ^0.3
php-http/curl-client Version ^1.7
jolicode/slack-php-api Version ^1.0
ext-json Version *