mirror of
https://github.com/henrywhitaker3/Speedtest-Tracker.git
synced 2025-12-30 09:45:10 +01:00
Added v1.9.1 files
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications;
|
||||
|
||||
use App\Helpers\NotificationsHelper;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Notifications\Messages\SlackMessage;
|
||||
use Illuminate\Notifications\Notification;
|
||||
|
||||
class SpeedtestAbsoluteThresholdNotificationSlack extends Notification
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
protected $errors;
|
||||
|
||||
/**
|
||||
* Create a new notification instance.
|
||||
*
|
||||
* @param array $errors
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(array $errors)
|
||||
{
|
||||
$this->errors = $errors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the notification's delivery channels.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return array
|
||||
*/
|
||||
public function via($notifiable)
|
||||
{
|
||||
return ['slack'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Format slack notification
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return SlackMessage
|
||||
*/
|
||||
public function toSlack($notifiable)
|
||||
{
|
||||
$msg = NotificationsHelper::formatAbsoluteThresholdMessage($this->errors);
|
||||
|
||||
return (new SlackMessage)
|
||||
->warning()
|
||||
->attachment(function ($attachment) use ($msg) {
|
||||
$attachment->title('Speedtest absolute threshold error')
|
||||
->content($msg);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user