From 03bfc9dbfcbad3ea3e8dbb26e5d44723057141ad Mon Sep 17 00:00:00 2001 From: Deon George Date: Sun, 26 May 2024 12:35:13 +1000 Subject: [PATCH] Fix path on rejected echomails, change layout of message_path quoting original message and control lines --- app/Notifications/Netmails/EchoareaNotExist.php | 1 + app/Traits/MessagePath.php | 16 ++++++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/app/Notifications/Netmails/EchoareaNotExist.php b/app/Notifications/Netmails/EchoareaNotExist.php index c21622d..0565b11 100644 --- a/app/Notifications/Netmails/EchoareaNotExist.php +++ b/app/Notifications/Netmails/EchoareaNotExist.php @@ -44,6 +44,7 @@ class EchoareaNotExist extends Netmails Log::info(sprintf('%s:+ Creating ECHOAREA NOT EXIST netmail to [%s]',self::LOGKEY,$ao->ftn)); + $o->to = $this->mo->from; $o->subject = 'Echoarea doesnt exist - '.$this->mo->set->get('set_echoarea'); // Message diff --git a/app/Traits/MessagePath.php b/app/Traits/MessagePath.php index ed0a335..cdadef8 100644 --- a/app/Traits/MessagePath.php +++ b/app/Traits/MessagePath.php @@ -13,12 +13,12 @@ trait MessagePath { $reply = "This is your original message:\r\r"; - $reply .= "+--[ BEGIN MESSAGE ]----------------------------------+\r"; + $reply .= "+------------------------------------[ BEGIN MESSAGE ]-+\r"; $reply .= sprintf("TO: %s\r",$mo->to); $reply .= sprintf("SUBJECT: %s\r",$mo->subject); $reply .= str_replace("\r---","\r#--",$mo->msg)."\r"; - $reply .= "+--[ CONTROL LINES ]----------------------------------+\r"; + $reply .= "+------------------------------------[ CONTROL LINES ]-+\r"; $reply .= sprintf("DATE: %s\r",$mo->date->format('Y-m-d H:i:s')); if ($mo->msgid) $reply .= sprintf("MSGID: %s\r",$mo->msgid); @@ -28,22 +28,26 @@ trait MessagePath foreach ($mo->kludges as $k=>$v) $reply .= sprintf("%s %s\r",$k,$v); - $reply .= "+--[ PATH ]-------------------------------------------+\r"; + $reply .= "+---------------------------------------------[ PATH ]-+\r"; if ($mo->path->count()) if ($mo instanceof Netmail) { foreach ($mo->path as $o) $reply .= sprintf("VIA: %s\r",$mo->via($o)); - } else { + } elseif ($mo instanceof Echomail) { + // Rejected echomails dont have a collection of Address::class for paths foreach ($mo->path as $o) - $reply .= sprintf("VIA: %s\r",$o->ftn); + $reply .= sprintf("VIA: %s\r",(is_string($o) ? $o : $o->ftn)); + + } else { + throw new \Exception('Message object is not an Netmail or Echomail?'); } else $reply .= "No path information? This would be normal if this message came directly to the hub\r"; - $reply .= "+--[ END MESSAGE ]------------------------------------+\r\r"; + $reply .= "+--------------------------------------[ END MESSAGE ]-+\r\r"; return $reply; }