From daba4a78d3add6715624b6d01f8212e0716958c2 Mon Sep 17 00:00:00 2001 From: Deon George Date: Wed, 16 Feb 2022 23:01:55 +1100 Subject: [PATCH] Fix echoarea name is converted to UC, add netmail VIA lines for outgoing netmail --- app/Classes/FTN/Message.php | 10 +++++----- app/Jobs/MessageProcess.php | 18 ++++++++++++------ app/Models/Netmail.php | 9 +++++---- .../2022_01_01_235631_create_mail.php | 4 ++-- 4 files changed, 24 insertions(+), 17 deletions(-) diff --git a/app/Classes/FTN/Message.php b/app/Classes/FTN/Message.php index c1f2866..86fcf56 100644 --- a/app/Classes/FTN/Message.php +++ b/app/Classes/FTN/Message.php @@ -10,7 +10,7 @@ use Illuminate\Support\Facades\Validator; use Illuminate\Validation\Validator as ValidatorResult; use App\Classes\FTN as FTNBase; -use App\Models\{Address,Domain,Zone}; +use App\Models\{Address,Domain,Setup,Zone}; use App\Rules\{TwoByteInteger,TwoByteIntegerWithZero}; use App\Traits\EncodeUTF8; @@ -412,7 +412,7 @@ class Message extends FTNBase $return .= sprintf("\01%s%s\r",$v,$x); } - $return .= $this->message."\r"; + $return .= $this->message; if ($this->tagline) $return .= sprintf("... %s\r",$this->tagline); if ($this->tearline) @@ -421,12 +421,12 @@ class Message extends FTNBase $return .= sprintf(" * Origin: %s\r",$this->origin); } else { - $return .= $this->message."\r"; + $return .= $this->message; } if ($this->isNetmail()) { - foreach ($this->via as $v) - $return .= sprintf("\01Via %s\r",$v); + foreach ($this->via as $via) + $return .= sprintf("\01Via %s\r",$via); } else { // Seenby & PATH - FSC-0068 diff --git a/app/Jobs/MessageProcess.php b/app/Jobs/MessageProcess.php index aa0978f..9668b61 100644 --- a/app/Jobs/MessageProcess.php +++ b/app/Jobs/MessageProcess.php @@ -94,9 +94,9 @@ class MessageProcess implements ShouldQueue $reply .= sprintf("MSGID: %s\r",$this->msg->msgid); foreach ($this->msg->kludge as $k=>$v) - $reply .= sprintf("@%s: %s\n",strtoupper($k),$v); + $reply .= sprintf("@%s: %s\r",strtoupper($k),$v); foreach ($this->msg->via as $via) - $reply .= sprintf("VIA: %s\n",$via); + $reply .= sprintf("VIA: %s\r",$via); $reply .= "------------------------------ END MESSAGE ------------------------------\r"; @@ -138,12 +138,12 @@ class MessageProcess implements ShouldQueue // Else we are echomail } else { - $ea = Echoarea::where('name',$this->msg->echoarea) + $ea = Echoarea::where('name',strtoupper($this->msg->echoarea)) ->where('domain_id',$this->msg->fboss_o->zone->domain_id) ->single(); if (! $ea) { - Log::alert(sprintf('%s:! Echo area [%s] doesnt exist for zone [%s]',self::LOGKEY,$this->msg->echoarea,$this->msg->fboss_o->zone->domain_id)); + Log::alert(sprintf('%s:! Echo area [%s] doesnt exist for zone [%d]',self::LOGKEY,$this->msg->echoarea,$this->msg->fboss_o->zone->zone_id)); return; } @@ -215,7 +215,7 @@ class MessageProcess implements ShouldQueue $o->echoarea_id = $ea->id; $o->msgid = $this->msg->msgid; - $o->msg = $this->msg->message_src; + $o->msg = $this->msg->message_src."\r"; $o->msg_crc = md5($this->msg->message); $o->rogue_seenby = $this->msg->rogue_seenby; $o->rogue_path = $this->msg->rogue_path; @@ -260,7 +260,13 @@ class MessageProcess implements ShouldQueue $o->msgid = $msg->msgid; $o->subject = $msg->subject; - $o->msg = $msg->message_src; + $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; } diff --git a/app/Models/Netmail.php b/app/Models/Netmail.php index 71b9369..78e11e2 100644 --- a/app/Models/Netmail.php +++ b/app/Models/Netmail.php @@ -34,7 +34,6 @@ final class Netmail extends Model implements Packet public function fftn() { return $this - ->setConnection('pgsql') ->belongsTo(Address::class) ->withTrashed(); } @@ -42,7 +41,6 @@ final class Netmail extends Model implements Packet public function tftn() { return $this - ->setConnection('pgsql') ->belongsTo(Address::class); } @@ -83,17 +81,20 @@ final class Netmail extends Model implements Packet if ($this->replyid) $o->replyid = $this->replyid; + $o->kludge->put('dbid',$this->id); + $o->message = $this->msg; $o->tagline = $this->tagline; $o->tearline = $this->tearline; // VIA kludge + $sysaddress = Setup::findOrFail(config('app.id'))->system->match($this->fftn->zone)->first(); $via = $this->via ?: collect(); $via->push( sprintf('%s @%s.UTC %s %d.%d/%s %s', - $this->fftn->ftn3d, + $sysaddress->ftn3d, Carbon::now()->utc()->format('Ymd.His'), - Setup::PRODUCT_NAME, + str_replace(' ','_',Setup::PRODUCT_NAME), Setup::PRODUCT_VERSION_MAJ, Setup::PRODUCT_VERSION_MIN, (new Setup)->version, diff --git a/database/migrations/2022_01_01_235631_create_mail.php b/database/migrations/2022_01_01_235631_create_mail.php index 42151e1..3e86d31 100644 --- a/database/migrations/2022_01_01_235631_create_mail.php +++ b/database/migrations/2022_01_01_235631_create_mail.php @@ -29,7 +29,7 @@ class CreateMail extends Migration $table->string('replyid')->nullable(); $table->text('msg'); - $table->string('msg_src')->nullable(); + $table->text('msg_src')->nullable(); $table->string('msg_crc')->nullable(); $table->string('tagline')->nullable(); $table->string('tearline')->nullable(); @@ -96,7 +96,7 @@ class CreateMail extends Migration $table->text('msg'); $table->text('msg_src')->nullable(); - $table->integer('msg_crc')->nullable(); + $table->string('msg_crc')->nullable(); $table->string('tagline')->nullable(); $table->string('tearline')->nullable();