Skip to content

Commit

Permalink
Merge pull request #69 from Carnicero90/custom-queues
Browse files Browse the repository at this point in the history
implementing custom queues for notifications
  • Loading branch information
denisdulici authored Oct 2, 2023
2 parents 6291290 + 4d7bcf0 commit b01b55b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/Config/firewall.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
'name' => env('FIREWALL_EMAIL_NAME', 'Laravel Firewall'),
'from' => env('FIREWALL_EMAIL_FROM', '[email protected]'),
'to' => env('FIREWALL_EMAIL_TO', '[email protected]'),
'queue' => env('FIREWALL_EMAIL_QUEUE', 'default'),
],

'slack' => [
Expand All @@ -48,6 +49,7 @@
'from' => env('FIREWALL_SLACK_FROM', 'Laravel Firewall'),
'to' => env('FIREWALL_SLACK_TO'), // webhook url
'channel' => env('FIREWALL_SLACK_CHANNEL', null), // set null to use the default channel of webhook
'queue' => env('FIREWALL_SLACK_QUEUE', 'default'),
],

],
Expand Down
14 changes: 11 additions & 3 deletions src/Notifications/AttackDetected.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@ class AttackDetected extends Notification implements ShouldQueue

/**
* The notification config.
*
* @var object
*/
public $notifications;
public array $notifications;

/**
* Create a notification instance.
Expand Down Expand Up @@ -58,6 +56,16 @@ public function via($notifiable)
return $channels;
}

/**
* Get the notification's queues.
* @return array|string
*/

public function viaQueues(): array
{
return array_map(fn ($channel) => $channel['queue'] ?? 'default', $this->notifications);
}

/**
* Build the mail representation of the notification.
*
Expand Down

0 comments on commit b01b55b

Please sign in to comment.