Skip to content

Commit 633d3b3

Browse files
authored
chore: Switch Apprise to markdown (alexjustesen#2531)
1 parent 61df96b commit 633d3b3

File tree

6 files changed

+33
-20
lines changed

6 files changed

+33
-20
lines changed

app/Listeners/ProcessCompletedSpeedtest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ private function notifyAppriseChannels(Result $result): void
8888
}
8989

9090
Notification::route('apprise_urls', $channelUrl)
91-
->notify(new SpeedtestNotification($title, $body, 'info'));
91+
->notify(new SpeedtestNotification($title, $body, 'info', 'markdown'));
9292
}
9393
}
9494

app/Listeners/ProcessUnhealthySpeedtest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ private function notifyAppriseChannels(Result $result): void
110110
}
111111

112112
Notification::route('apprise_urls', $channelUrl)
113-
->notify(new SpeedtestNotification($title, $body, 'warning'));
113+
->notify(new SpeedtestNotification($title, $body, 'warning', 'markdown'));
114114
}
115115
}
116116

app/Notifications/Apprise/SpeedtestNotification.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public function __construct(
1414
public string $title,
1515
public string $body,
1616
public string $type = 'info',
17+
public string $format = 'markdown',
1718
) {}
1819

1920
/**
@@ -35,6 +36,7 @@ public function toApprise(object $notifiable): AppriseMessage
3536
->urls($notifiable->routes['apprise_urls'])
3637
->title($this->title)
3738
->body($this->body)
38-
->type($this->type);
39+
->type($this->type)
40+
->format($this->format);
3941
}
4042
}

app/Notifications/Apprise/TestNotification.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,14 @@ public function via(object $notifiable): array
2525
*/
2626
public function toApprise(object $notifiable): AppriseMessage
2727
{
28+
$body = '👋 This is a test notification from **'.config('app.name')."**.\n\n";
29+
$body .= "If you're seeing this, your Apprise notification channel is configured correctly!\n\n";
30+
2831
return AppriseMessage::create()
2932
->urls($notifiable->routes['apprise_urls'])
3033
->title('Test Notification')
31-
->body('👋 Testing the Apprise notification channel.')
32-
->type('info');
34+
->body($body)
35+
->type('info')
36+
->format('markdown');
3337
}
3438
}
Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
A new speedtest on {{ config('app.name') }} was completed using {{ $service }}.
1+
A new speedtest on **{{ config('app.name') }}** was completed using **{{ $service }}**.
22

3-
Server name: {{ $serverName }}
4-
Server ID: {{ $serverId }}
5-
ISP: {{ $isp }}
6-
Ping: {{ $ping }}
7-
Download: {{ $download }}
8-
Upload: {{ $upload }}
9-
Packet Loss: {{ $packetLoss }} %
10-
Ookla Speedtest: {{ $speedtest_url }}
11-
URL: {{ $url }}
3+
### Results
4+
- **Server:** {{ $serverName }} (ID: {{ $serverId }})
5+
- **ISP:** {{ $isp }}
6+
- **Ping:** {{ $ping }}
7+
- **Download:** {{ $download }}
8+
- **Upload:** {{ $upload }}
9+
- **Packet Loss:** {{ $packetLoss }}%
10+
11+
### Links
12+
- [View Ookla Results]({{ $speedtest_url }})
13+
- [View Dashboard]({{ $url }})
Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1-
A new speedtest on **{{ config('app.name') }}** was completed using **{{ $service }}** on **{{ $isp }}** but a threshold was breached.
2-
1+
A new speedtest on **{{ config('app.name') }}** was completed using **{{ $service }}** on **{{ $isp }}** but a threshold was breached
2+
### Failed Metrics
33
@foreach ($metrics as $item)
4-
- **{{ $item['name'] }}** {{ $item['threshold'] }}: {{ $item['value'] }}
4+
- **{{ $item['name'] }}**
5+
- **Threshold:** {{ $item['threshold'] }} | **Actual:** {{ $item['value'] }}
56
@endforeach
6-
- **Ookla Speedtest:** {{ $speedtest_url }}
7-
- **URL:** {{ $url }}
7+
### Server Information
8+
- **Server:** {{ $serverName }} (ID: {{ $serverId }})
9+
- **ISP:** {{ $isp }}
10+
### Links
11+
- [View Ookla Results]({{ $speedtest_url }})
12+
- [View Dashboard]({{ $url }})

0 commit comments

Comments
 (0)