Skip to content

Commit b01b55b

Browse files
authored
Merge pull request #69 from Carnicero90/custom-queues
implementing custom queues for notifications
2 parents 6291290 + 4d7bcf0 commit b01b55b

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

src/Config/firewall.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
'name' => env('FIREWALL_EMAIL_NAME', 'Laravel Firewall'),
4141
'from' => env('FIREWALL_EMAIL_FROM', '[email protected]'),
4242
'to' => env('FIREWALL_EMAIL_TO', '[email protected]'),
43+
'queue' => env('FIREWALL_EMAIL_QUEUE', 'default'),
4344
],
4445

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

5355
],

src/Notifications/AttackDetected.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,8 @@ class AttackDetected extends Notification implements ShouldQueue
2121

2222
/**
2323
* The notification config.
24-
*
25-
* @var object
2624
*/
27-
public $notifications;
25+
public array $notifications;
2826

2927
/**
3028
* Create a notification instance.
@@ -58,6 +56,16 @@ public function via($notifiable)
5856
return $channels;
5957
}
6058

59+
/**
60+
* Get the notification's queues.
61+
* @return array|string
62+
*/
63+
64+
public function viaQueues(): array
65+
{
66+
return array_map(fn ($channel) => $channel['queue'] ?? 'default', $this->notifications);
67+
}
68+
6169
/**
6270
* Build the mail representation of the notification.
6371
*

0 commit comments

Comments
 (0)