Multiple enhancements to interactive messages, moved messages to Notifications, send netmail back when invalid packet password

This commit is contained in:
2023-07-23 17:27:52 +10:00
parent 9f0fa0a8ec
commit 17fe7e910d
28 changed files with 837 additions and 475 deletions

View File

@@ -9,9 +9,11 @@ use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Notification;
use App\Classes\FTN\{Message,Process};
use App\Classes\FTN\Message;
use App\Models\{Address,Echoarea,Echomail,Netmail,Setup};
use App\Notifications\Netmails\Reject;
class MessageProcess implements ShouldQueue
{
@@ -83,7 +85,29 @@ class MessageProcess implements ShouldQueue
// @todo Enable checks to see if this is a file request or file send
$o = $this->create_netmail($this->msg);
$o = new Netmail;
$o->to = $this->msg->user_to;
$o->from = $this->msg->user_from;
$o->fftn_id = ($x=$this->msg->fftn_o) ? $x->id : NULL;
$o->tftn_id = ($x=$this->msg->tftn_o) ? $x->id : NULL;
$o->datetime = $this->msg->date;
$o->tzoffset = $this->msg->date->utcOffset();
$o->flags = $this->msg->flags;
$o->cost = $this->msg->cost;
$o->msgid = $this->msg->msgid;
$o->subject = $this->msg->subject;
$o->msg = $this->msg->message;
foreach ($this->msg->via as $v)
$o->msg .= sprintf("\01Via %s\r",$v);
$o->msg_src = $this->msg->message_src;
$o->msg_crc = md5($this->msg->message);
$o->set_pkt = $this->packet;
$o->set_sender = $this->sender;
$o->set_path = $this->msg->pathaddress;
@@ -133,52 +157,9 @@ class MessageProcess implements ShouldQueue
// If not processed, no users here!
if (! $processed) {
$reject = [
'ÚÄ¿ÚÄ¿ ÂÚÄ¿ÚĿڿ',
'³ ³ÄÙ ³³ÄÙ³ ³ ',
'Á ÀÄÙÀÄÙÀÄÙÀÄÙ Á '
];
Log::alert(sprintf('%s:! Netmail to the Hub from (%s) [%s] but no users here.',self::LOGKEY,$this->msg->user_from,$this->msg->fftn));
$reply = "Your Netmail was not processed by the hub and cannot be delivered to anybody (as there are no users here).\r";
$reply .= "\r";
$reply .= "\r";
$reply .= "This is your original message:\r";
$reply .= "------------------------------ BEGIN MESSAGE ------------------------------\r";
$reply .= sprintf("TO: %s\r",$this->msg->user_to);
$reply .= sprintf("SUBJECT: %s\r",$this->msg->subject);
$reply .= str_replace("\r---","\r#--",$this->msg->message)."\r";
$reply .= "------------------------------ CONTROL LINES ------------------------------\r";
$reply .= sprintf("DATE: %s\r",$this->msg->date->format('Y-m-d H:i:s'));
$reply .= sprintf("MSGID: %s\r",$this->msg->msgid);
foreach ($this->msg->kludge as $k=>$v)
$reply .= sprintf("@%s: %s\r",strtoupper($k),$v);
foreach ($this->msg->via as $via)
$reply .= sprintf("VIA: %s\r",$via);
$reply .= "------------------------------ END MESSAGE ------------------------------\r";
$o = new Netmail;
$o->to = $this->msg->user_from;
$o->from = Setup::PRODUCT_NAME;
$o->subject = 'Message Undeliverable - '.$this->msg->msgid;
$o->datetime = $this->msg->date;
$o->tzoffset = $this->msg->date->utcOffset();
$o->cost = 0;
$o->flags = Message::FLAG_LOCAL|Message::FLAG_PRIVATE;
$o->fftn_id = ($x=$this->msg->tftn_o) ? $x->id : NULL;
$o->tftn_id = ($x=$this->msg->fftn_o) ? $x->id : NULL;
$o->replyid = $this->msg->msgid;
$o->msg = Process::format_msg($reply,$reject);
$o->tagline = 'Do you think it was fate which brought us together? Nah, bad luck :(';
$o->tearline = sprintf('%s (%04X)',Setup::PRODUCT_NAME,Setup::PRODUCT_ID);
$o->save();
Notification::route('netmail',$this->msg->fftn_o)->notify(new Reject($this->msg));
}
// If in transit, store for collection
@@ -319,32 +300,4 @@ class MessageProcess implements ShouldQueue
}
}
}
private function create_netmail(Message $msg): Netmail
{
$o = new Netmail;
$o->to = $msg->user_to;
$o->from = $msg->user_from;
$o->fftn_id = ($x=$msg->fftn_o) ? $x->id : NULL;
$o->tftn_id = ($x=$msg->tftn_o) ? $x->id : NULL;
$o->datetime = $msg->date;
$o->tzoffset = $msg->date->utcOffset();
$o->flags = $msg->flags;
$o->cost = $msg->cost;
$o->msgid = $msg->msgid;
$o->subject = $msg->subject;
$o->msg = $msg->message;
foreach ($msg->via as $v)
$o->msg .= sprintf("\01Via %s\r",$v);
$o->msg_src = $msg->message_src;
$o->msg_crc = md5($msg->message); // @todo DB schema needs to handle this
return $o;
}
}