Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/Actions/Notifications/SendTelegramTestNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand Down
4 changes: 3 additions & 1 deletion app/Notifications/Telegram/SpeedtestNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class SpeedtestNotification extends Notification implements ShouldQueue
public function __construct(
public string $content,
public bool $disableNotification = false,
public ?int $messageThreadId = null,
) {}

/**
Expand All @@ -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]);
}
}
7 changes: 5 additions & 2 deletions app/Notifications/Telegram/TestNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand All @@ -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]);
}
}
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.