clrghouz/app/Notifications/Channels/NetmailChannel.php

50 lines
1.0 KiB
PHP
Raw Normal View History

2021-11-26 13:36:57 +00:00
<?php
namespace App\Notifications\Channels;
use Illuminate\Notifications\Notification;
use Illuminate\Support\Facades\Log;
use App\Models\Netmail;
use App\Jobs\AddressPoll as Job;
class NetmailChannel
{
private const LOGKEY = 'CN-';
/**
* The HTTP client instance.
*
* @var Netmail
*/
protected Netmail $netmail;
/**
* Create a new Slack channel instance.
*
* @param Netmail $o
*/
public function __construct(Netmail $o)
{
$this->netmail = $o;
}
/**
* Send the given notification.
*
* @param mixed $notifiable
* @param \Illuminate\Notifications\Notification $notification
* @return \Psr\Http\Message\ResponseInterface|null
*/
public function send($notifiable,Notification $notification)
{
if (! $ao = $notifiable->routeNotificationFor('netmail',$notification))
return;
$o = $notification->toNetmail($notifiable);
Log::info(sprintf('%s:Test Netmail created [%s]',self::LOGKEY,$o->id));
Job::dispatch($ao);
Log::info(sprintf('%s:Dispatched job to pool address [%s]',self::LOGKEY,$ao->ftn));
}
}