diff --git a/app/Actions/Notifications/SendTelegramTestNotification.php b/app/Actions/Notifications/SendTelegramTestNotification.php index c7c64a815..94f81a523 100644 --- a/app/Actions/Notifications/SendTelegramTestNotification.php +++ b/app/Actions/Notifications/SendTelegramTestNotification.php @@ -11,7 +11,7 @@ class SendTelegramTestNotification { use AsAction; - public function handle(array $recipients) + public function handle(array $recipients, ?int $messageThreadId = null) { if (! count($recipients)) { Notification::make() @@ -24,7 +24,7 @@ public function handle(array $recipients) foreach ($recipients as $recipient) { FacadesNotification::route('telegram_chat_id', $recipient['telegram_chat_id']) - ->notify(new TestNotification); + ->notify(new TestNotification($messageThreadId)); } Notification::make() diff --git a/app/Notifications/Telegram/SpeedtestNotification.php b/app/Notifications/Telegram/SpeedtestNotification.php index 5317f7bf9..02f239c54 100644 --- a/app/Notifications/Telegram/SpeedtestNotification.php +++ b/app/Notifications/Telegram/SpeedtestNotification.php @@ -17,6 +17,7 @@ class SpeedtestNotification extends Notification implements ShouldQueue public function __construct( public string $content, public bool $disableNotification = false, + public ?int $messageThreadId = null, ) {} /** @@ -39,6 +40,7 @@ public function toTelegram($notifiable): TelegramMessage return TelegramMessage::create() ->to($notifiable->routes['telegram_chat_id']) ->content($this->content) - ->disableNotification($this->disableNotification); + ->disableNotification($this->disableNotification) + ->options(['message_thread_id' => $this->messageThreadId]); } } diff --git a/app/Notifications/Telegram/TestNotification.php b/app/Notifications/Telegram/TestNotification.php index 111ddc47d..4cd278028 100644 --- a/app/Notifications/Telegram/TestNotification.php +++ b/app/Notifications/Telegram/TestNotification.php @@ -13,15 +13,17 @@ class TestNotification extends Notification implements ShouldQueue use Queueable; protected $settings; + protected ?int $messageThreadId; /** * Create a new notification instance. * * @return void */ - public function __construct() + public function __construct(?int $messageThreadId = null) { $this->settings = new NotificationSettings; + $this->messageThreadId = $messageThreadId; } /** @@ -43,7 +45,8 @@ public function toTelegram(object $notifiable): TelegramMessage { return TelegramMessage::create() ->to($notifiable->routes['telegram_chat_id']) + ->content('👋 Testing the Telegram notification channel.') ->disableNotification($this->settings->telegram_disable_notification) - ->content('👋 Testing the Telegram notification channel.'); + ->options(['message_thread_id' => $this->messageThreadId]); } } diff --git a/package-lock.json b/package-lock.json index a7e3f6825..779226e9c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5 +1,5 @@ { - "name": "html", + "name": "speedtest-tracker", "lockfileVersion": 3, "requires": true, "packages": {