2023-08-02 12:42:59 +00:00
< ? php
namespace App\Notifications\Netmails ;
use Illuminate\Support\Facades\Log ;
use App\Notifications\Netmails ;
2024-05-19 13:28:45 +00:00
use App\Models\ { Address , Netmail };
2023-08-02 12:42:59 +00:00
use App\Traits\ { MessagePath , PageTemplate };
class NetmailForward extends Netmails
{
use MessagePath , PageTemplate ;
private const LOGKEY = 'NNP' ;
private Address $ao ;
2024-05-19 13:28:45 +00:00
private Netmail $mo ;
2023-08-02 12:42:59 +00:00
/**
* Reply to a netmail ping request .
*
2024-05-19 13:28:45 +00:00
* @ param Netmail $mo
2023-08-02 12:42:59 +00:00
* @ param Address $ao
*/
2024-05-19 13:28:45 +00:00
public function __construct ( Netmail $mo , Address $ao )
2023-08-02 12:42:59 +00:00
{
parent :: __construct ();
$this -> mo = $mo ;
$this -> ao = $ao ;
}
/**
* 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-08-02 12:42:59 +00:00
{
2023-12-18 04:13:16 +00:00
$o = $this -> setupNetmail ( $notifiable );
2023-08-02 12:42:59 +00:00
$ao = $notifiable -> routeNotificationFor ( static :: via );
2024-05-19 13:28:45 +00:00
Log :: info ( sprintf ( '%s:+ Advising [%s@%s] that netmail to [%s] will be forwarded to [%s].' , self :: LOGKEY , $this -> mo -> from , $ao -> ftn , $this -> mo -> to , $this -> ao -> ftn ));
2023-08-02 12:42:59 +00:00
2024-05-19 13:28:45 +00:00
$o -> to = $this -> mo -> from ;
2023-08-02 12:42:59 +00:00
$o -> replyid = $this -> mo -> msgid ;
$o -> subject = sprintf ( 'Your netmail is being forwarded to %s' , $this -> ao -> ftn3d );
// Message
$msg = $this -> page ( FALSE , 'Forward' );
$msg -> addText ( " Howdy, Clrghouz is not a BBS, so users cannot login to collect netmail. \r \r \r " );
$msg -> addText ( sprintf ( " Never fear, your msg [%s] to [%s] has been forwarded, to [%s]. \r \r " ,
$this -> mo -> msgid ,
2024-05-19 13:28:45 +00:00
$this -> mo -> to ,
2023-08-02 12:42:59 +00:00
$this -> ao -> ftn3d ,
));
2024-05-19 13:28:45 +00:00
$msg -> addText ( sprintf ( " To avoid receiving this netmail, send messages to [%s] to [%s]. \r \r " , $this -> mo -> to , $this -> ao -> ftn3d ));
2023-08-02 12:42:59 +00:00
$o -> msg = $msg -> render ();
2024-06-03 09:08:40 +00:00
$o -> set_tagline = 'Thank you so much for your mail. I love it already.' ;
2023-08-02 12:42:59 +00:00
$o -> save ();
return $o ;
}
}