Skip to content

Commit

Permalink
discord notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
markvaneijk committed Apr 8, 2024
1 parent 7a54d8f commit b3d400d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"require": {
"php": "^8.1",
"illuminate/contracts": "^10.8.0",
"laravel-notification-channels/discord": "^1.4",
"laravel-notification-channels/discord": "^1.6",
"laravel-notification-channels/telegram": "^4.0",
"laravel/helpers": "^1.6",
"laravel/slack-notification-channel": "^2.5",
Expand Down
6 changes: 4 additions & 2 deletions src/Listeners/Concerns/SendsNotifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ public function send(Notification $notification, array $channels): void
return;
}

foreach($accounts as $account) {
Notifications::route($channel, $account)->notify($notification);
foreach($accounts as $route) {
Notifications::route($channel, $route)->notify(
$notification->on($channel),
);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Notifications/BounceNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function getMessage(): string
'🔥', '🧯', '‼️', '⁉️', '🔴', '📣', '😅', '🥵',
]);

return implode(' ', [$emoji, 'mail has bounced']);
return "{$emoji} Mail has bounced";
}

public function toMail(): MailMessage
Expand Down
8 changes: 8 additions & 0 deletions src/Notifications/Concerns/HasDynamicDrivers.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ public function on($drivers, bool $merge = false): static
$drivers = array_merge($this->drivers, $drivers);
}

$via = [
'discord' => \NotificationChannels\Discord\DiscordChannel::class,
];

$drivers = array_map(function($driver) use ($via) {
return $via[$driver];
}, $drivers);

$this->drivers = $drivers;

return $this;
Expand Down

0 comments on commit b3d400d

Please sign in to comment.