2023-09-20 10:29:23 +00:00
< ? php
namespace App\Notifications\Netmails ;
use Carbon\Carbon ;
use Illuminate\Support\Facades\Log ;
use App\Classes\FTN\Message ;
use App\Notifications\Netmails ;
2024-05-19 13:28:45 +00:00
use App\Models\Netmail ;
2023-09-20 10:29:23 +00:00
use App\Traits\ { MessagePath , PageTemplate };
class EchomailBadAddress extends Netmails
{
use MessagePath , PageTemplate ;
private const LOGKEY = 'NBA' ;
private Message $mo ;
/**
* Send a sysop a message if they give us a message with a bad address in it .
*
* @ param Message $mo
*/
public function __construct ( Message $mo )
{
parent :: __construct ();
$this -> mo = $mo ;
}
/**
* Get the mail representation of the notification .
*
* @ param mixed $notifiable
* @ return Netmail
* @ throws \Exception
*/
2023-12-18 04:13:16 +00:00
public function toNetmail ( object $notifiable ) : Netmail
2023-09-20 10:29:23 +00:00
{
2023-12-18 04:13:16 +00:00
$o = $this -> setupNetmail ( $notifiable );
2023-09-20 10:29:23 +00:00
$ao = $notifiable -> routeNotificationFor ( static :: via );
Log :: info ( sprintf ( '%s:+ Creating ECHOMAIL BAD ADDRESS netmail to [%s]' , self :: LOGKEY , $ao -> ftn ));
$o -> subject = sprintf ( 'Bad address in echomail [%s]' , $this -> mo -> msgid );
// Message
$msg = $this -> page ( FALSE , 'badmsg' );
$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 ,
2024-05-19 13:28:45 +00:00
$this -> mo -> to ,
2023-09-20 10:29:23 +00:00
Carbon :: now () -> utc () -> toDateTimeString (),
$this -> mo -> date -> utc () -> toDateTimeString (),
)
);
$msg -> addText ( sprintf ( " The address in this echomail [%s] is the wrong address for this domain [%s]. \r \r " , $this -> mo -> fftn , $ao -> zone -> domain -> name ));
$msg -> addText ( " This echomail has been rejected and not stored here - so no downstream nodes will receive it. If you think this is a mistake, please let me know. \r \r " );
$msg -> addText ( $this -> message_path ( $this -> mo ));
$o -> msg = $msg -> render ();
$o -> tagline = 'I enjoyed reading your message, even though nobody else will get it :)' ;
$o -> save ();
return $o ;
}
}