clrghouz/app/Notifications/Netmails/EchoareaNotSubscribed.php
Deon George 8fb3a21fcd
All checks were successful
Create Docker Image / Build Docker Image (x86_64) (push) Successful in 39s
Create Docker Image / Build Docker Image (arm64) (push) Successful in 1m51s
Create Docker Image / Final Docker Image Manifest (push) Successful in 10s
Normalise tagline/tearline/origin
2024-06-03 19:09:09 +10:00

73 lines
1.9 KiB
PHP

<?php
namespace App\Notifications\Netmails;
use Carbon\Carbon;
use Illuminate\Support\Facades\Log;
use App\Notifications\Netmails;
use App\Models\{Echomail,Netmail};
use App\Traits\{MessagePath,PageTemplate};
class EchoareaNotSubscribed extends Netmails
{
use MessagePath,PageTemplate;
private const LOGKEY = 'NNW';
private Echomail $mo;
/**
* Send a sysop a message if they write to an area that they hadnt previously subscribed to.
*
* @param Echomail $mo
*/
public function __construct(Echomail $mo)
{
parent::__construct();
$this->mo = $mo;
}
/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
* @return Netmail
* @throws \Exception
*/
public function toNetmail(object $notifiable): Netmail
{
$o = $this->setupNetmail($notifiable);
$ao = $notifiable->routeNotificationFor(static::via);
Log::info(sprintf('%s:+ Creating ECHOAREA NOT SUBSCRIBED netmail to [%s]',self::LOGKEY,$ao->ftn));
$o->subject = 'Echoarea not subscribed - '.$this->mo->echoarea->name;
// Message
$msg = $this->page(FALSE,'nosub');
$msg->addText(
sprintf("Your echomail with ID [%s] to [%s] here was received here on [%s] and it looks like you sent it on [%s].\r\r",
$this->mo->msgid,
$this->mo->to,
Carbon::now()->utc()->toDateTimeString(),
$this->mo->date->utc()->toDateTimeString(),
)
);
$msg->addText(sprintf("It appears that you havent been previously subscribed to this echoarea using the address [%s].\r\r",$ao->ftn));
$msg->addText("Even though your post was accepted, I'm not configured to export any posts to you when others respond, you might like to log in to the web interface and do that.\r\r");
$msg->addText($this->message_path($this->mo));
$o->msg = $msg->render();
$o->set_tagline = 'Don\'t let your trash become someone else\'s treasure. Feed your shredder.';
$o->save();
return $o;
}
}