Skip to content

Commit bf56509

Browse files
Require recipient Telegram and validate bot token (alexjustesen#324)
Co-authored-by: Alex Justesen <[email protected]>
1 parent 105529c commit bf56509

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

app/Filament/Pages/Settings/NotificationPage.php

100644100755
Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,19 +214,27 @@ public function sendTestTelegramNotification()
214214
{
215215
$notificationSettings = new (NotificationSettings::class);
216216

217-
if (count($notificationSettings->telegram_recipients)) {
217+
$bot = config('telegram.bot');
218+
219+
if (blank($bot)) {
220+
Notification::make()
221+
->title('First you need to add \'TELEGRAM_BOT_TOKEN\' on your .env file or add it as environment variable')
222+
->warning()
223+
->send();
224+
}
225+
if (! empty($notificationSettings->telegram_recipients)) {
218226
foreach ($notificationSettings->telegram_recipients as $recipient) {
219227
\Illuminate\Support\Facades\Notification::route('telegram_chat_id', $recipient['telegram_chat_id'])
220228
->notify(new TelegramNotification('Test notification channel *telegram*'));
221229
}
222230

223231
Notification::make()
224-
->title('Test telegram notification sent.')
232+
->title('Test Telegram notification sent.')
225233
->success()
226234
->send();
227235
} else {
228236
Notification::make()
229-
->title('You need to add recipients to receive telegram notifications.')
237+
->title('You need to add recipients to receive Telegram notifications.')
230238
->warning()
231239
->send();
232240
}

config/telegram.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
return [
4+
'bot' => env('TELEGRAM_BOT_TOKEN', null),
5+
];

0 commit comments

Comments
 (0)