Skip to content

Commit ee7eb16

Browse files
committed
Improvements
- Check for telegram channel class in route for. - Refactor telegram notification channel binding.
1 parent 6b1b5af commit ee7eb16

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

src/TelegramChannel.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,10 @@ public function send($notifiable, Notification $notification): ?array
5252
}
5353

5454
if ($message->toNotGiven()) {
55-
if (! $to = $notifiable->routeNotificationFor('telegram', $notification)) {
55+
$to = $notifiable->routeNotificationFor('telegram', $notification)
56+
?? $notifiable->routeNotificationFor(self::class, $notification);
57+
58+
if (! $to) {
5659
return null;
5760
}
5861

src/TelegramServiceProvider.php

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace NotificationChannels\Telegram;
44

55
use GuzzleHttp\Client as HttpClient;
6-
use Illuminate\Contracts\Events\Dispatcher;
76
use Illuminate\Notifications\ChannelManager;
87
use Illuminate\Support\Facades\Notification;
98
use Illuminate\Support\ServiceProvider;
@@ -34,16 +33,9 @@ public function boot(): void
3433
*/
3534
public function register()
3635
{
37-
Notification::resolved(function (ChannelManager $service) {
38-
$service->extend('telegram', function ($app) {
39-
return new TelegramChannel(
40-
new Telegram(
41-
config('services.telegram-bot-api.token'),
42-
app(HttpClient::class),
43-
config('services.telegram-bot-api.base_uri')
44-
),
45-
app(Dispatcher::class)
46-
);
36+
Notification::resolved(static function (ChannelManager $service) {
37+
$service->extend('telegram', static function ($app) {
38+
return $app->make(TelegramChannel::class);
4739
});
4840
});
4941
}

0 commit comments

Comments
 (0)