RSM-38 Added Discord Routing for relevant notifications

This commit is contained in:
2020-10-10 00:39:53 +01:00
parent 2a43e213f9
commit 82123b1c26
9 changed files with 90 additions and 16 deletions

View File

@@ -2,6 +2,9 @@
namespace App\Notifications;
use App\Facades\Options;
use App\Traits\DiscordRoutable;
use Awssat\Notifications\Messages\DiscordMessage;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
@@ -11,7 +14,7 @@ use App\Application;
class ApplicationDenied extends Notification implements ShouldQueue
{
use Queueable;
use Queueable, DiscordRoutable;
public $application;
@@ -34,14 +37,22 @@ class ApplicationDenied extends Notification implements ShouldQueue
*/
public function via($notifiable)
{
return ['mail', 'slack'];
$options = ['mail'];
if (Options::getOption('enable_discord_notifications'))
array_push($options, 'discord');
if (Options::getOption('enable_slack_notifications'))
array_push($options, 'slack');
return $options;
}
/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage
* @return MailMessage
*/
public function toMail($notifiable)
{
@@ -70,6 +81,13 @@ class ApplicationDenied extends Notification implements ShouldQueue
});
}
public function toDiscord($notifiable)
{
// SlackMessage is similar to DiscordMessage, so they're compatible
return $this->toSlack($notifiable);
}
/**
* Get the array representation of the notification.
*