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
17 changes: 13 additions & 4 deletions app/Filament/Pages/Settings/NotificationPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,7 @@ public function form(Form $form): Form
->label('Enable Discord webhook notifications')
->reactive()
->columnSpanFull(),
Forms\Components\Grid::make([
'default' => 1,
])
Forms\Components\Grid::make(['default' => 1])
->hidden(fn (Forms\Get $get) => $get('discord_enabled') !== true)
->schema([
Forms\Components\Fieldset::make('Triggers')
Expand All @@ -164,6 +162,7 @@ public function form(Form $form): Form
->columnSpanFull(),
Forms\Components\Toggle::make('discord_on_threshold_failure')
->label('Notify on threshold failures')
->reactive()
->columnSpanFull(),
]),
Forms\Components\Repeater::make('discord_webhooks')
Expand All @@ -176,6 +175,17 @@ public function form(Form $form): Form
->url(),
])
->columnSpanFull(),
Forms\Components\Fieldset::make('discord_user_mention')
->label('Discord User Mention')
->hidden(fn (Forms\Get $get) => $get('discord_on_threshold_failure') !== true)
->schema([
Forms\Components\TextInput::make('discord_user_mention')
->label('User ID')
->placeholder('Enter the Discord User ID')
->maxLength(18)
->helperText('This should be the numeric User ID from Discord (e.g., 123456789012345678)'),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of using the helperText can you add a hint that says "Get User ID" with a link out to the Discord docs here: https://support.discord.com/hc/en-us/articles/206346498-Where-can-I-find-my-User-Server-Message-ID#h_01HRSTXPS5H5D7JBY2QKKPVKNA

])
->columnSpanFull(),
Forms\Components\Actions::make([
Forms\Components\Actions\Action::make('test discord')
->label('Test Discord webhook')
Expand All @@ -189,7 +199,6 @@ public function form(Form $form): Form
'default' => 1,
'md' => 2,
]),

Forms\Components\Section::make('Gotify')
->schema([
Forms\Components\Toggle::make('gotify_enabled')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public function handle(SpeedtestCompleted $event): void
'metrics' => $failed,
'speedtest_url' => $event->result->result_url,
'url' => url('/admin/results'),
'mentionUser' => $notificationSettings->discord_user_mention,
])->render(),
];

Expand Down
2 changes: 2 additions & 0 deletions app/Settings/NotificationSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ class NotificationSettings extends Settings

public ?array $discord_webhooks;

public ?string $discord_user_mention;

public bool $ntfy_enabled;

public bool $ntfy_on_speedtest_run;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

use Spatie\LaravelSettings\Migrations\SettingsMigration;

return new class extends SettingsMigration
{
public function up(): void
{
$this->migrator->add('notification.discord_user_mention', null);
}

public function down(): void
{
$this->migrator->delete('notification.discord_user_mention');
}
};
4 changes: 4 additions & 0 deletions resources/views/discord/speedtest-threshold.blade.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
**Speedtest Threshold Breached - #{{ $id }}**

@if (!empty($mentionUser))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not required but you could also use the new @blank and @filled directives merged in #1951.

{!! "<@{$mentionUser}>" !!}
@endif

A new speedtest on **{{ config('app.name') }}** was completed using **{{ $service }}** on **{{ $isp }}** but a threshold was breached.

@foreach ($metrics as $item)
Expand Down