Skip to content

Commit

Permalink
Add data to notification failed event (#156)
Browse files Browse the repository at this point in the history
  • Loading branch information
irazasyed authored Oct 14, 2022
1 parent eb50c93 commit 6ca14f4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
11 changes: 5 additions & 6 deletions src/TelegramChannel.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,11 @@ public function send(mixed $notifiable, Notification $notification): ?array
try {
$response = $message->send();
} catch (CouldNotSendNotification $exception) {
$this->dispatcher->dispatch(new NotificationFailed(
$notifiable,
$notification,
'telegram',
[]
));
$this->dispatcher->dispatch(new NotificationFailed($notifiable, $notification, 'telegram', [
'to' => $message->getPayloadValue('chat_id'),
'request' => $message->toArray(),
'exception' => $exception,
]));

throw $exception;
}
Expand Down
8 changes: 7 additions & 1 deletion tests/Feature/TelegramChannelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
$notifiable = new TestNotifiable();
$notification = new TestNotification();

$payload = $notification->toTelegram($notifiable)->toArray();

$this->telegram
->shouldReceive('sendMessage')
->andThrow($exception_class, $exception_message);
Expand All @@ -43,7 +45,11 @@
$notifiable,
$notification,
'telegram',
[]
[
'to' => $payload['chat_id'],
'request' => $payload,
'exception' => new $exception_class($exception_message),
]
)
);

Expand Down

0 comments on commit 6ca14f4

Please sign in to comment.