@@ -31,11 +31,17 @@ public function handle(SpeedtestCompleted $event): void
3131 {
3232 $ result = $ event ->result ;
3333
34- $ result ->loadMissing (['dispatchedBy ' ]);
34+ if ($ result ->healthy === false ) {
35+ return ;
36+ }
37+
38+ // Don't send notifications for unscheduled speedtests.
39+ if ($ result ->unscheduled ) {
40+ return ;
41+ }
3542
3643 $ this ->notifyAppriseChannels ($ result );
3744 $ this ->notifyDatabaseChannels ($ result );
38- $ this ->notifyDispatchingUser ($ result );
3945 $ this ->notifyMailChannels ($ result );
4046 $ this ->notifyWebhookChannels ($ result );
4147 }
@@ -45,11 +51,6 @@ public function handle(SpeedtestCompleted $event): void
4551 */
4652 private function notifyAppriseChannels (Result $ result ): void
4753 {
48- // Don't send Apprise notification if dispatched by a user or test is unhealthy.
49- if (filled ($ result ->dispatched_by ) || $ result ->healthy === false ) {
50- return ;
51- }
52-
5354 // Check if Apprise notifications are enabled.
5455 if (! $ this ->notificationSettings ->apprise_enabled || ! $ this ->notificationSettings ->apprise_on_speedtest_run ) {
5556 return ;
@@ -97,11 +98,6 @@ private function notifyAppriseChannels(Result $result): void
9798 */
9899 private function notifyDatabaseChannels (Result $ result ): void
99100 {
100- // Don't send database notification if dispatched by a user or test is unhealthy.
101- if (filled ($ result ->dispatched_by ) || $ result ->healthy === false ) {
102- return ;
103- }
104-
105101 // Check if database notifications are enabled.
106102 if (! $ this ->notificationSettings ->database_enabled || ! $ this ->notificationSettings ->database_on_speedtest_run ) {
107103 return ;
@@ -120,37 +116,11 @@ private function notifyDatabaseChannels(Result $result): void
120116 }
121117 }
122118
123- /**
124- * Notify the user who dispatched the speedtest.
125- */
126- private function notifyDispatchingUser (Result $ result ): void
127- {
128- if (empty ($ result ->dispatched_by ) || ! $ result ->healthy ) {
129- return ;
130- }
131-
132- $ result ->dispatchedBy ->notify (
133- FilamentNotification::make ()
134- ->title (__ ('results.speedtest_completed ' ))
135- ->actions ([
136- Action::make ('view ' )
137- ->label (__ ('general.view ' ))
138- ->url (route ('filament.admin.resources.results.index ' )),
139- ])
140- ->success ()
141- ->toDatabase (),
142- );
143- }
144-
145119 /**
146120 * Notify mail channels.
147121 */
148122 private function notifyMailChannels (Result $ result ): void
149123 {
150- if (filled ($ result ->dispatched_by ) || $ result ->healthy === false ) {
151- return ;
152- }
153-
154124 if (! $ this ->notificationSettings ->mail_enabled || ! $ this ->notificationSettings ->mail_on_speedtest_run ) {
155125 return ;
156126 }
@@ -172,11 +142,6 @@ private function notifyMailChannels(Result $result): void
172142 */
173143 private function notifyWebhookChannels (Result $ result ): void
174144 {
175- // Don't send webhook if dispatched by a user or test is unhealthy.
176- if (filled ($ result ->dispatched_by ) || $ result ->healthy === false ) {
177- return ;
178- }
179-
180145 // Check if webhook notifications are enabled.
181146 if (! $ this ->notificationSettings ->webhook_enabled || ! $ this ->notificationSettings ->webhook_on_speedtest_run ) {
182147 return ;
0 commit comments