2023-09-20 10:29:23 +00:00
< ? php
namespace App\Notifications\Netmails ;
use Illuminate\Support\Facades\Log ;
use App\Notifications\Netmails ;
2024-05-21 11:41:23 +00:00
use App\Models\ { Echomail , 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' ;
2024-05-21 11:41:23 +00:00
private Echomail $mo ;
2023-09-20 10:29:23 +00:00
/**
* Send a sysop a message if they give us a message with a bad address in it .
*
2024-05-21 11:41:23 +00:00
* @ param Echomail $mo
2023-09-20 10:29:23 +00:00
*/
2024-05-21 11:41:23 +00:00
public function __construct ( Echomail $mo )
2023-09-20 10:29:23 +00:00
{
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' );
2024-06-28 13:27:06 +00:00
$msg -> addText ( $this -> sourceSummary ( $this -> mo ) . " \r \r " );
2023-09-20 10:29:23 +00:00
2024-07-11 13:33:17 +00:00
$msg -> addText ( sprintf ( " The address in this echomail [%s] is the wrong address for the domain [%s]. \r \r " , $this -> mo -> fftn , $ao -> zone -> domain -> name ));
2023-09-20 10:29:23 +00:00
$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 ();
2024-06-03 09:08:40 +00:00
$o -> set_tagline = 'I enjoyed reading your message, even though nobody else will get it :)' ;
2023-09-20 10:29:23 +00:00
$o -> save ();
return $o ;
}
}