2023-08-16 17:18:50 +02:00
< ? php
namespace App\Notifications\Server ;
use App\Models\Server ;
use App\Notifications\Channels\DiscordChannel ;
use App\Notifications\Channels\EmailChannel ;
use Illuminate\Bus\Queueable ;
use Illuminate\Contracts\Queue\ShouldQueue ;
use Illuminate\Notifications\Messages\MailMessage ;
use Illuminate\Notifications\Notification ;
use Illuminate\Support\Str ;
class NotReachable extends Notification implements ShouldQueue
{
use Queueable ;
2023-09-08 16:53:19 +02:00
public $tries = 5 ;
2023-08-16 17:18:50 +02:00
public function __construct ( public Server $server )
{
}
public function via ( object $notifiable ) : array
{
2023-09-06 14:31:38 +02:00
return setNotificationChannels ( $notifiable , 'status_changes' );
2023-08-16 17:18:50 +02:00
}
public function toMail () : MailMessage
{
$mail = new MailMessage ();
// $fqdn = $this->fqdn;
$mail -> subject ( " ⛔ Server ' { $this -> server -> name } ' is unreachable " );
// $mail->view('emails.application-status-changes', [
// 'name' => $this->application_name,
// 'fqdn' => $fqdn,
// 'application_url' => $this->application_url,
// ]);
return $mail ;
}
public function toDiscord () : string
{
$message = '⛔ Server \'' . $this -> server -> name . '\' is unreachable (could be a temporary issue). If you receive this more than twice in a row, please check your server.' ;
return $message ;
}
2023-09-06 14:31:38 +02:00
public function toTelegram () : array
{
return [
" message " => '⛔ Server \'' . $this -> server -> name . '\' is unreachable (could be a temporary issue). If you receive this more than twice in a row, please check your server.'
];
}
2023-08-16 17:18:50 +02:00
}