2023-07-23 07:27:52 +00:00
< ? php
namespace App\Notifications\Netmails ;
use Carbon\Carbon ;
use Illuminate\Support\Facades\Log ;
use App\Notifications\Netmails ;
2024-05-19 13:28:45 +00:00
use App\Models\Netmail ;
2023-07-23 07:27:52 +00:00
use App\Traits\ { MessagePath , PageTemplate };
2024-05-19 13:28:45 +00:00
class NetmailHubNoUser extends Netmails
2023-07-23 07:27:52 +00:00
{
use MessagePath , PageTemplate ;
private const LOGKEY = 'NNP' ;
2024-05-19 13:28:45 +00:00
private Netmail $mo ;
2023-07-23 07:27:52 +00:00
/**
* Reply to a netmail ping request .
*
2024-05-19 13:28:45 +00:00
* @ param Netmail $mo
2023-07-23 07:27:52 +00:00
*/
2024-05-19 13:28:45 +00:00
public function __construct ( Netmail $mo )
2023-07-23 07:27:52 +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-07-23 07:27:52 +00:00
{
2023-12-18 04:13:16 +00:00
$o = $this -> setupNetmail ( $notifiable );
2023-07-23 07:27:52 +00:00
$ao = $notifiable -> routeNotificationFor ( static :: via );
2024-05-19 13:28:45 +00:00
Log :: info ( sprintf ( '%s:+ Creating HUB NO USER netmail to [%s]' , self :: LOGKEY , $ao -> ftn ));
2023-07-23 07:27:52 +00:00
2024-05-19 13:28:45 +00:00
$o -> to = $this -> mo -> from ;
2023-07-23 07:27:52 +00:00
$o -> replyid = $this -> mo -> msgid ;
$o -> subject = 'Message Undeliverable - ' . $this -> mo -> msgid ;
// Message
$msg = $this -> page ( FALSE , 'Reject' );
$msg -> addText (
sprintf ( " Your netmail 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-07-23 07:27:52 +00:00
Carbon :: now () -> utc () -> toDateTimeString (),
$this -> mo -> date -> utc () -> toDateTimeString (),
)
);
$msg -> addText ( " This hub is not attended, so no user will be able to read your message (the hub is unattended). You may like to try and contact them another way. \r \r " );
$msg -> addText ( $this -> message_path ( $this -> mo ));
$o -> msg = $msg -> render ();
$o -> tagline = 'Do you think it was fate which brought us together? Nah, bad luck :(' ;
$o -> save ();
return $o ;
}
}