2023-07-23 07:27:52 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add show the message detail
|
|
|
|
*/
|
|
|
|
namespace App\Traits;
|
|
|
|
|
2024-05-17 12:10:54 +00:00
|
|
|
use App\Models\{Echomail,Netmail};
|
2023-07-23 07:27:52 +00:00
|
|
|
|
|
|
|
trait MessagePath
|
|
|
|
{
|
2024-05-17 12:10:54 +00:00
|
|
|
protected function message_path(Echomail|Netmail $mo): string
|
2023-07-23 07:27:52 +00:00
|
|
|
{
|
|
|
|
$reply = "This is your original message:\r\r";
|
|
|
|
|
2024-07-30 10:54:47 +00:00
|
|
|
$reply .= "+---------------------------------------------------------[ BEGIN MESSAGE ]-+\r";
|
2024-05-17 12:10:54 +00:00
|
|
|
$reply .= sprintf("TO: %s\r",$mo->to);
|
2023-07-23 07:27:52 +00:00
|
|
|
$reply .= sprintf("SUBJECT: %s\r",$mo->subject);
|
2024-05-17 12:10:54 +00:00
|
|
|
$reply .= str_replace("\r---","\r#--",$mo->msg)."\r";
|
2023-07-23 07:27:52 +00:00
|
|
|
|
2024-07-30 10:54:47 +00:00
|
|
|
$reply .= "+---------------------------------------------------------[ CONTROL LINES ]-+\r";
|
|
|
|
|
2024-06-28 08:28:12 +00:00
|
|
|
$reply .= sprintf("DATE: %s\r",$mo->date->format('Y-m-d H:i:s'));
|
2024-05-25 04:12:04 +00:00
|
|
|
if ($mo->msgid)
|
|
|
|
$reply .= sprintf("MSGID: %s\r",$mo->msgid);
|
|
|
|
if ($mo->replyid)
|
|
|
|
$reply .= sprintf("REPLY: %s\r",$mo->replyid);
|
2023-07-23 07:27:52 +00:00
|
|
|
|
2024-05-17 12:10:54 +00:00
|
|
|
foreach ($mo->kludges as $k=>$v)
|
|
|
|
$reply .= sprintf("%s %s\r",$k,$v);
|
2023-07-23 07:27:52 +00:00
|
|
|
|
2024-07-30 10:54:47 +00:00
|
|
|
$reply .= "+------------------------------------------------------------------[ PATH ]-+\r";
|
2023-07-23 07:27:52 +00:00
|
|
|
|
2024-05-19 13:28:45 +00:00
|
|
|
if ($mo->path->count())
|
|
|
|
if ($mo instanceof Netmail) {
|
2024-05-31 11:57:21 +00:00
|
|
|
// Incoming processed message havent converted the path into a collection of addresses yet
|
2024-05-19 13:28:45 +00:00
|
|
|
foreach ($mo->path as $o)
|
2024-05-31 11:57:21 +00:00
|
|
|
$reply .= sprintf("VIA: %s\r",(is_string($o) ? $o : $mo->via($o)));
|
2024-05-19 13:28:45 +00:00
|
|
|
|
2024-05-26 02:35:13 +00:00
|
|
|
} elseif ($mo instanceof Echomail) {
|
|
|
|
// Rejected echomails dont have a collection of Address::class for paths
|
2024-05-19 13:28:45 +00:00
|
|
|
foreach ($mo->path as $o)
|
2024-07-30 10:54:47 +00:00
|
|
|
$reply .= sprintf("PATH: %s\r",(is_string($o) ? $o : $o->ftn));
|
2024-05-26 02:35:13 +00:00
|
|
|
|
|
|
|
} else {
|
|
|
|
throw new \Exception('Message object is not an Netmail or Echomail?');
|
2024-05-19 13:28:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
$reply .= "No path information? This would be normal if this message came directly to the hub\r";
|
2023-07-23 07:27:52 +00:00
|
|
|
|
2024-07-30 10:54:47 +00:00
|
|
|
$reply .= "+----------------------------------------------------------------[ ORIGIN ]-+\r";
|
2024-12-04 05:06:36 +00:00
|
|
|
$reply .= sprintf("%s (%s)\r",($mo->getRelationValue('origin')?->value) ?: '*NO ORIGIN*',$mo->fftn->ftn4d);
|
2024-07-30 10:54:47 +00:00
|
|
|
|
|
|
|
$reply .= "+-----------------------------------------------------------[ END MESSAGE ]-+\r";
|
2023-07-23 07:27:52 +00:00
|
|
|
|
|
|
|
return $reply;
|
|
|
|
}
|
|
|
|
}
|