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;
|
2024-06-28 13:27:06 +00:00
|
|
|
use App\Models\{Echoarea,Echomail,Netmail,Setup};
|
2023-07-23 07:27:52 +00:00
|
|
|
|
|
|
|
abstract class Echomails extends Notification //implements ShouldQueue
|
|
|
|
{
|
|
|
|
use Queueable;
|
|
|
|
|
|
|
|
protected const via = 'echomail';
|
|
|
|
|
|
|
|
private const LOGKEY = 'NN-';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new notification instance.
|
|
|
|
*/
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
$this->queue = 'echomail';
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the notification's delivery channels.
|
|
|
|
*
|
|
|
|
* @param mixed $notifiable
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function via($notifiable)
|
|
|
|
{
|
|
|
|
return [ self::via ];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the mail representation of the notification.
|
|
|
|
*
|
|
|
|
* @param mixed $notifiable
|
|
|
|
* @return Echomail
|
|
|
|
* @throws \Exception
|
|
|
|
*/
|
2023-12-18 04:13:16 +00:00
|
|
|
abstract public function toEchomail(object $notifiable): Echomail;
|
2023-07-23 07:27:52 +00:00
|
|
|
|
2024-05-25 12:25:57 +00:00
|
|
|
protected function setupEchomail(Echoarea $eo): Echomail
|
2023-07-23 07:27:52 +00:00
|
|
|
{
|
|
|
|
$o = new Echomail;
|
|
|
|
$o->from = Setup::PRODUCT_NAME;
|
2024-05-25 12:25:57 +00:00
|
|
|
|
|
|
|
$o->echoarea_id = $eo->id;
|
2023-07-23 07:27:52 +00:00
|
|
|
|
2024-06-28 13:27:06 +00:00
|
|
|
$o->datetime = Carbon::now()->utc();
|
|
|
|
$o->tzoffset = Carbon::now()->utcOffset();
|
2023-07-23 07:27:52 +00:00
|
|
|
|
|
|
|
$o->flags = (Message::FLAG_LOCAL);
|
|
|
|
|
2024-06-03 09:08:40 +00:00
|
|
|
$o->set_tearline = sprintf('%s (%04X)',Setup::PRODUCT_NAME,Setup::PRODUCT_ID);
|
2023-07-23 07:27:52 +00:00
|
|
|
|
|
|
|
return $o;
|
|
|
|
}
|
2024-06-28 13:27:06 +00:00
|
|
|
|
|
|
|
protected function sourceSummary(Echomail|Netmail $o,string $item=NULL): string
|
|
|
|
{
|
|
|
|
return sprintf("Your %s was received here on [%s] and it looks like you sent it on [%s].",
|
|
|
|
$item ?: sprintf('%s with ID [%s] to [%s]',$o instanceof Netmail ? 'Netmail' : 'Echomail',$o->msgid,$o->to),
|
|
|
|
Carbon::now()->utc()->toDateTimeString(),
|
|
|
|
$o->date->utc()->toDateTimeString(),
|
|
|
|
);
|
|
|
|
}
|
2023-07-23 07:27:52 +00:00
|
|
|
}
|