| @@ 13-56 (lines=44) @@ | ||
| 10 | use Spatie\ServerMonitor\Models\Enums\CheckStatus; |
|
| 11 | use Spatie\ServerMonitor\Notifications\BaseNotification; |
|
| 12 | ||
| 13 | class CheckRestored extends BaseNotification |
|
| 14 | { |
|
| 15 | /** @var \Spatie\ServerMonitor\Events\CheckWarning */ |
|
| 16 | public $event; |
|
| 17 | ||
| 18 | /** |
|
| 19 | * Get the mail representation of the notification. |
|
| 20 | * |
|
| 21 | * @param mixed $notifiable |
|
| 22 | * @return \Illuminate\Notifications\Messages\MailMessage |
|
| 23 | */ |
|
| 24 | public function toMail($notifiable) |
|
| 25 | { |
|
| 26 | return (new MailMessage) |
|
| 27 | ->success() |
|
| 28 | ->subject($this->getSubject()) |
|
| 29 | ->line($this->getMessageText()); |
|
| 30 | } |
|
| 31 | ||
| 32 | public function toSlack($notifiable) |
|
| 33 | { |
|
| 34 | return (new SlackMessage) |
|
| 35 | ->success() |
|
| 36 | ->attachment(function (SlackAttachment $attachment) { |
|
| 37 | $attachment |
|
| 38 | ->title($this->getSubject()) |
|
| 39 | ->content($this->getMessageText()) |
|
| 40 | ->fallback($this->getMessageText()) |
|
| 41 | ->timestamp(Carbon::now()); |
|
| 42 | }); |
|
| 43 | } |
|
| 44 | ||
| 45 | public function setEvent(CheckRestoredEvent $event) |
|
| 46 | { |
|
| 47 | $this->event = $event; |
|
| 48 | ||
| 49 | return $this; |
|
| 50 | } |
|
| 51 | ||
| 52 | public function shouldSend(): bool |
|
| 53 | { |
|
| 54 | return $this->getCheck()->hasStatus(CheckStatus::SUCCESS); |
|
| 55 | } |
|
| 56 | } |
|
| 57 | ||
| @@ 13-54 (lines=42) @@ | ||
| 10 | use Spatie\ServerMonitor\Models\Enums\CheckStatus; |
|
| 11 | use Spatie\ServerMonitor\Notifications\BaseNotification; |
|
| 12 | ||
| 13 | class CheckSucceeded extends BaseNotification |
|
| 14 | { |
|
| 15 | /** @var \Spatie\ServerMonitor\Events\CheckWarning */ |
|
| 16 | public $event; |
|
| 17 | ||
| 18 | /** |
|
| 19 | * Get the mail representation of the notification. |
|
| 20 | * |
|
| 21 | * @param mixed $notifiable |
|
| 22 | * @return \Illuminate\Notifications\Messages\MailMessage |
|
| 23 | */ |
|
| 24 | public function toMail($notifiable) |
|
| 25 | { |
|
| 26 | return (new MailMessage) |
|
| 27 | ->subject($this->getSubject()) |
|
| 28 | ->line($this->getMessageText()); |
|
| 29 | } |
|
| 30 | ||
| 31 | public function toSlack($notifiable) |
|
| 32 | { |
|
| 33 | return (new SlackMessage) |
|
| 34 | ->attachment(function (SlackAttachment $attachment) { |
|
| 35 | $attachment |
|
| 36 | ->title($this->getSubject()) |
|
| 37 | ->content($this->getMessageText()) |
|
| 38 | ->fallback($this->getMessageText()) |
|
| 39 | ->timestamp(Carbon::now()); |
|
| 40 | }); |
|
| 41 | } |
|
| 42 | ||
| 43 | public function setEvent(CheckSucceededEvent $event) |
|
| 44 | { |
|
| 45 | $this->event = $event; |
|
| 46 | ||
| 47 | return $this; |
|
| 48 | } |
|
| 49 | ||
| 50 | public function shouldSend(): bool |
|
| 51 | { |
|
| 52 | return $this->getCheck()->hasStatus(CheckStatus::SUCCESS); |
|
| 53 | } |
|
| 54 | } |
|
| 55 | ||