Skip to content

Commit 6ca14f4

Browse files
authored
Add data to notification failed event (#156)
1 parent eb50c93 commit 6ca14f4

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

src/TelegramChannel.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,11 @@ public function send(mixed $notifiable, Notification $notification): ?array
6161
try {
6262
$response = $message->send();
6363
} catch (CouldNotSendNotification $exception) {
64-
$this->dispatcher->dispatch(new NotificationFailed(
65-
$notifiable,
66-
$notification,
67-
'telegram',
68-
[]
69-
));
64+
$this->dispatcher->dispatch(new NotificationFailed($notifiable, $notification, 'telegram', [
65+
'to' => $message->getPayloadValue('chat_id'),
66+
'request' => $message->toArray(),
67+
'exception' => $exception,
68+
]));
7069

7170
throw $exception;
7271
}

tests/Feature/TelegramChannelTest.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
$notifiable = new TestNotifiable();
3232
$notification = new TestNotification();
3333

34+
$payload = $notification->toTelegram($notifiable)->toArray();
35+
3436
$this->telegram
3537
->shouldReceive('sendMessage')
3638
->andThrow($exception_class, $exception_message);
@@ -43,7 +45,11 @@
4345
$notifiable,
4446
$notification,
4547
'telegram',
46-
[]
48+
[
49+
'to' => $payload['chat_id'],
50+
'request' => $payload,
51+
'exception' => new $exception_class($exception_message),
52+
]
4753
)
4854
);
4955

0 commit comments

Comments
 (0)