| @@ 11-50 (lines=40) @@ | ||
| 8 | use Spatie\UptimeMonitor\Events\SiteDown as SiteDownEvent; |
|
| 9 | use Spatie\UptimeMonitor\Models\UptimeMonitor; |
|
| 10 | ||
| 11 | class SiteDown extends Notification |
|
| 12 | { |
|
| 13 | /** @var \Spatie\UptimeMonitor\Events\SiteDown */ |
|
| 14 | protected $event; |
|
| 15 | ||
| 16 | /** |
|
| 17 | * Get the mail representation of the notification. |
|
| 18 | * |
|
| 19 | * @param mixed $notifiable |
|
| 20 | * @return \Illuminate\Notifications\Messages\MailMessage |
|
| 21 | */ |
|
| 22 | public function toMail($notifiable) |
|
| 23 | { |
|
| 24 | $mailMessage = (new MailMessage) |
|
| 25 | ->error() |
|
| 26 | ->subject("Site {$this->event->uptimeMonitor->url} is down.") |
|
| 27 | ->line("Site is down"); |
|
| 28 | ||
| 29 | return $mailMessage; |
|
| 30 | } |
|
| 31 | ||
| 32 | public function toSlack($notifiable) |
|
| 33 | { |
|
| 34 | return (new SlackMessage) |
|
| 35 | ->error() |
|
| 36 | ->content("Site {$this->event->uptimeMonitor->url} is down"); |
|
| 37 | } |
|
| 38 | ||
| 39 | public function isStillRelevant(): bool |
|
| 40 | { |
|
| 41 | return $this->event->uptimeMonitor->status == UptimeMonitor::STATUS_DOWN; |
|
| 42 | } |
|
| 43 | ||
| 44 | public function setEvent(SiteDownEvent $event) |
|
| 45 | { |
|
| 46 | $this->event = $event; |
|
| 47 | ||
| 48 | return $this; |
|
| 49 | } |
|
| 50 | } |
|
| 51 | ||
| @@ 11-50 (lines=40) @@ | ||
| 8 | use Spatie\UptimeMonitor\Events\SiteDown as SiteDownEvent; |
|
| 9 | use Spatie\UptimeMonitor\Models\UptimeMonitor; |
|
| 10 | ||
| 11 | class SiteRestored extends Notification |
|
| 12 | { |
|
| 13 | /** @var \Spatie\UptimeMonitor\Events\SiteDown */ |
|
| 14 | protected $event; |
|
| 15 | ||
| 16 | /** |
|
| 17 | * Get the mail representation of the notification. |
|
| 18 | * |
|
| 19 | * @param mixed $notifiable |
|
| 20 | * @return \Illuminate\Notifications\Messages\MailMessage |
|
| 21 | */ |
|
| 22 | public function toMail($notifiable) |
|
| 23 | { |
|
| 24 | $mailMessage = (new MailMessage) |
|
| 25 | ->success() |
|
| 26 | ->subject("Site {$this->event->uptimeMonitor->url} has been restored.") |
|
| 27 | ->line("Site has been restored"); |
|
| 28 | ||
| 29 | return $mailMessage; |
|
| 30 | } |
|
| 31 | ||
| 32 | public function toSlack($notifiable) |
|
| 33 | { |
|
| 34 | return (new SlackMessage) |
|
| 35 | ->success() |
|
| 36 | ->content("Site {$this->event->uptimeMonitor->url} has been restored"); |
|
| 37 | } |
|
| 38 | ||
| 39 | public function isStillRelevant(): bool |
|
| 40 | { |
|
| 41 | return $this->event->uptimeMonitor->status == UptimeMonitor::STATUS_UP; |
|
| 42 | } |
|
| 43 | ||
| 44 | public function setEvent(SiteDownEvent $event) |
|
| 45 | { |
|
| 46 | $this->event = $event; |
|
| 47 | ||
| 48 | return $this; |
|
| 49 | } |
|
| 50 | } |
|
| 51 | ||
| @@ 11-50 (lines=40) @@ | ||
| 8 | use Spatie\UptimeMonitor\Events\SiteDown as SiteDownEvent; |
|
| 9 | use Spatie\UptimeMonitor\Models\UptimeMonitor; |
|
| 10 | ||
| 11 | class SiteUp extends Notification |
|
| 12 | { |
|
| 13 | /** @var \Spatie\UptimeMonitor\Events\SiteDown */ |
|
| 14 | protected $event; |
|
| 15 | ||
| 16 | /** |
|
| 17 | * Get the mail representation of the notification. |
|
| 18 | * |
|
| 19 | * @param mixed $notifiable |
|
| 20 | * @return \Illuminate\Notifications\Messages\MailMessage |
|
| 21 | */ |
|
| 22 | public function toMail($notifiable) |
|
| 23 | { |
|
| 24 | $mailMessage = (new MailMessage) |
|
| 25 | ->success() |
|
| 26 | ->subject("Site {$this->event->uptimeMonitor->url} is up.") |
|
| 27 | ->line("Site is up"); |
|
| 28 | ||
| 29 | return $mailMessage; |
|
| 30 | } |
|
| 31 | ||
| 32 | public function toSlack($notifiable) |
|
| 33 | { |
|
| 34 | return (new SlackMessage) |
|
| 35 | ->success() |
|
| 36 | ->content("Site {$this->event->uptimeMonitor->url} is up"); |
|
| 37 | } |
|
| 38 | ||
| 39 | public function isStillRelevant(): bool |
|
| 40 | { |
|
| 41 | return $this->event->uptimeMonitor->status == UptimeMonitor::STATUS_UP; |
|
| 42 | } |
|
| 43 | ||
| 44 | public function setEvent(SiteDownEvent $event) |
|
| 45 | { |
|
| 46 | $this->event = $event; |
|
| 47 | ||
| 48 | return $this; |
|
| 49 | } |
|
| 50 | } |
|
| 51 | ||