feat(notification): add Pushover
This commit is contained in:
@@ -5,6 +5,7 @@ namespace App\Notifications\ScheduledTask;
|
||||
use App\Models\ScheduledTask;
|
||||
use App\Notifications\CustomEmailNotification;
|
||||
use App\Notifications\Dto\DiscordMessage;
|
||||
use App\Notifications\Dto\PushoverMessage;
|
||||
use App\Notifications\Dto\SlackMessage;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
|
||||
@@ -70,6 +71,30 @@ class TaskFailed extends CustomEmailNotification
|
||||
];
|
||||
}
|
||||
|
||||
public function toPushover(): PushoverMessage
|
||||
{
|
||||
$message = "Scheduled task ({$this->task->name}) failed<br/>";
|
||||
|
||||
if ($this->output) {
|
||||
$message .= "<br/><b>Error Output:</b>{$this->output}";
|
||||
}
|
||||
|
||||
$buttons = [];
|
||||
if ($this->url) {
|
||||
$buttons[] = [
|
||||
'text' => 'Open task in Coolify',
|
||||
'url' => (string) $this->url,
|
||||
];
|
||||
}
|
||||
|
||||
return new PushoverMessage(
|
||||
title: 'Scheduled task failed',
|
||||
level: 'error',
|
||||
message: $message,
|
||||
buttons: $buttons,
|
||||
);
|
||||
}
|
||||
|
||||
public function toSlack(): SlackMessage
|
||||
{
|
||||
$title = 'Scheduled task failed';
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace App\Notifications\ScheduledTask;
|
||||
use App\Models\ScheduledTask;
|
||||
use App\Notifications\CustomEmailNotification;
|
||||
use App\Notifications\Dto\DiscordMessage;
|
||||
use App\Notifications\Dto\PushoverMessage;
|
||||
use App\Notifications\Dto\SlackMessage;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
|
||||
@@ -70,6 +71,25 @@ class TaskSuccess extends CustomEmailNotification
|
||||
];
|
||||
}
|
||||
|
||||
public function toPushover(): PushoverMessage
|
||||
{
|
||||
$message = "Coolify: Scheduled task ({$this->task->name}) succeeded.";
|
||||
$buttons = [];
|
||||
if ($this->url) {
|
||||
$buttons[] = [
|
||||
'text' => 'Open task in Coolify',
|
||||
'url' => (string) $this->url,
|
||||
];
|
||||
}
|
||||
|
||||
return new PushoverMessage(
|
||||
title: 'Scheduled task succeeded',
|
||||
level: 'success',
|
||||
message: $message,
|
||||
buttons: $buttons,
|
||||
);
|
||||
}
|
||||
|
||||
public function toSlack(): SlackMessage
|
||||
{
|
||||
$title = 'Scheduled task succeeded';
|
||||
|
||||
Reference in New Issue
Block a user