From f639e3ffab9b7c940d09f406145daa2d199c717e Mon Sep 17 00:00:00 2001 From: Deon George Date: Wed, 22 Nov 2023 13:14:21 +1100 Subject: [PATCH] New attempt to making sure echomails have origin and senders path/seenby details (rework of #45d7823) --- app/Jobs/MessageProcess.php | 17 +------------- app/Models/Echomail.php | 28 ++++++++++++++++++++++- resources/views/widgets/message.blade.php | 8 +++++++ 3 files changed, 36 insertions(+), 17 deletions(-) diff --git a/app/Jobs/MessageProcess.php b/app/Jobs/MessageProcess.php index 14c071f..77e95a2 100644 --- a/app/Jobs/MessageProcess.php +++ b/app/Jobs/MessageProcess.php @@ -364,26 +364,10 @@ class MessageProcess implements ShouldQueue if ($x=$this->msg->fboss_o) { $o->fftn_id = $x->id; - /* - // Make sure our sender and packet source are in the path - if (! $this->msg->path->contains($x->ftn)) { - Log::alert(sprintf('%s:? Echomail adding sender to PATH [%s].',self::LOGKEY,$x->ftn)); - - $this->msg->path->push($x->ftn); - } - */ - } else { $o->fftn_id = NULL; // @todo This should be the node that originated the message - but since that node is not in the DB it would be null } - /* - if (! $this->msg->path->contains($this->pktsrc->id)) { - Log::alert(sprintf('%s:? Echomail adding pktsrc to PATH [%s].',self::LOGKEY,$x->ftn)); - $this->msg->path->push($this->pktsrc->id); - } - */ - $o->echoarea_id = $ea->id; $o->msgid = $this->msg->msgid; $o->replyid = $this->msg->replyid; @@ -395,6 +379,7 @@ class MessageProcess implements ShouldQueue $o->set_path = $this->msg->path; $o->set_seenby = $this->msg->seenby; $o->set_recvtime = $this->recvtime; + $o->set_sender = $this->pktsrc->id; // Record receiving packet and sender $o->set_pkt = $this->packet; diff --git a/app/Models/Echomail.php b/app/Models/Echomail.php index 3143583..cf1ac33 100644 --- a/app/Models/Echomail.php +++ b/app/Models/Echomail.php @@ -24,6 +24,7 @@ final class Echomail extends Model implements Packet private Collection $set_path; private Carbon $set_recvtime; private string $set_pkt; + private string $set_sender; private bool $no_export = FALSE; protected $casts = [ @@ -52,6 +53,7 @@ final class Echomail extends Model implements Packet case 'no_export': case 'set_path': case 'set_pkt': + case 'set_sender': case 'set_recvtime': case 'set_seenby': $this->{$key} = $value; @@ -69,13 +71,25 @@ final class Echomail extends Model implements Packet // @todo if the message is updated with new SEEN-BY's from another route, we'll delete the pending export for systems (if there is one) static::created(function($model) { $rogue = collect(); - $seenby = NULL; + $seenby = collect(); $path = collect(); // Parse PATH if ($model->set_path->count()) $path = self::parseAddresses('path',$model->set_path,$model->fftn->zone,$rogue); + // Make sure our sender is first in the path + if (! $path->contains($model->fftn_id)) { + Log::alert(sprintf('%s:? Echomail adding sender to start of PATH [%s].',self::LOGKEY,$model->fftn_id)); + $path->prepend($model->fftn_id); + } + + // Make sure our pktsrc is last in the path + if (isset($model->set_sender) && (! $path->contains($model->set_sender))) { + Log::alert(sprintf('%s:? Echomail adding pktsrc to end of PATH [%s].',self::LOGKEY,$model->set_sender)); + $path->push($model->set_sender); + } + // Save the Path $ppoid = NULL; foreach ($path as $aoid) { @@ -94,6 +108,18 @@ final class Echomail extends Model implements Packet if ($model->set_seenby->count()) $seenby = self::parseAddresses('seenby',$model->set_seenby,$model->fftn->zone,$rogue); + // Make sure our sender is first in the seenby + if (! $seenby->contains($model->fftn_id)) { + Log::alert(sprintf('%s:? Echomail adding sender to SEENBY [%s].',self::LOGKEY,$model->fftn_id)); + $seenby->push($model->fftn_id); + } + + // Make sure our pktsrc is last in the seenby + if (isset($model->set_sender) && (! $seenby->contains($model->set_sender))) { + Log::alert(sprintf('%s:? Echomail adding pktsrc to SEENBY [%s].',self::LOGKEY,$model->set_sender)); + $seenby->push($model->set_sender); + } + if (count($rogue)) { $model->rogue_seenby = $rogue; $model->save(); diff --git a/resources/views/widgets/message.blade.php b/resources/views/widgets/message.blade.php index 96c81e1..845d516 100644 --- a/resources/views/widgets/message.blade.php +++ b/resources/views/widgets/message.blade.php @@ -44,6 +44,10 @@ use App\Classes\FTN\Message;
SEENBY:
{!! optimize_path($msg->seenby->pluck('ftn2d'))->join(', ') !!}
+ + @if ($msg->rogue_seenby->count()) +
[NOTE: Some seen-by values couldnt be identified - ({{ $msg->rogue_seenby->join(',') }})] + @endif @endif @@ -59,6 +63,10 @@ use App\Classes\FTN\Message;
PATH:
{!! optimize_path($msg->pathorder())->join(' -> ') !!} + + @if ($msg->rogue_path->count()) +
[NOTE: Some path values couldnt be identified - ({{ $msg->rogue_path->join(',') }})] + @endif