2023-07-23 07:27:52 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Notifications;
|
|
|
|
|
|
|
|
use Carbon\Carbon;
|
|
|
|
use Illuminate\Bus\Queueable;
|
|
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
|
|
use Illuminate\Notifications\Notification;
|
|
|
|
|
|
|
|
use App\Classes\FTN\Message;
|
|
|
|
use App\Models\{Netmail,Setup,System};
|
|
|
|
|
|
|
|
abstract class Netmails extends Notification //implements ShouldQueue
|
|
|
|
{
|
|
|
|
use Queueable;
|
|
|
|
|
|
|
|
protected const via = 'netmail';
|
|
|
|
|
|
|
|
private const LOGKEY = 'NN-';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new notification instance.
|
|
|
|
*/
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
$this->queue = 'netmail';
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the notification's delivery channels.
|
|
|
|
*
|
|
|
|
* @param mixed $notifiable
|
|
|
|
* @return array
|
2024-05-25 12:25:57 +00:00
|
|
|
* @todo change to object $notifiable
|
2023-07-23 07:27:52 +00:00
|
|
|
*/
|
|
|
|
public function via($notifiable)
|
|
|
|
{
|
|
|
|
return [ self::via ];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the mail representation of the notification.
|
|
|
|
*
|
|
|
|
* @param mixed $notifiable
|
|
|
|
* @return Netmail
|
|
|
|
* @throws \Exception
|
|
|
|
*/
|
2023-12-18 04:13:16 +00:00
|
|
|
abstract public function toNetmail(object $notifiable): Netmail;
|
2023-07-23 07:27:52 +00:00
|
|
|
|
2023-12-18 04:13:16 +00:00
|
|
|
protected function setupNetmail(object $notifiable): Netmail
|
2023-07-23 07:27:52 +00:00
|
|
|
{
|
2024-04-21 11:40:55 +00:00
|
|
|
// @todo Redirect netmails to Hubs or higher to the admin
|
2023-07-23 07:27:52 +00:00
|
|
|
$ao = $notifiable->routeNotificationFor(static::via);
|
|
|
|
|
|
|
|
$o = new Netmail;
|
|
|
|
$o->to = $ao->system->sysop;
|
|
|
|
$o->from = Setup::PRODUCT_NAME;
|
|
|
|
|
|
|
|
$o->datetime = Carbon::now();
|
|
|
|
$o->tzoffset = $o->datetime->utcOffset();
|
|
|
|
|
2024-05-19 13:28:45 +00:00
|
|
|
$o->fftn_id = our_address($ao)->id;
|
2023-07-23 07:27:52 +00:00
|
|
|
$o->tftn_id = $ao->id;
|
|
|
|
$o->flags = (Message::FLAG_LOCAL|Message::FLAG_PRIVATE);
|
|
|
|
$o->cost = 0;
|
|
|
|
|
|
|
|
$o->tearline = sprintf('%s (%04X)',Setup::PRODUCT_NAME,Setup::PRODUCT_ID);
|
|
|
|
|
|
|
|
return $o;
|
|
|
|
}
|
|
|
|
}
|