This commit is contained in:
root
2023-03-29 15:20:05 +00:00
parent 5ec489e0e0
commit a0bb8f2d1e
25468 changed files with 3063105 additions and 28 deletions

View File

@@ -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);
});
}
}