From f082bb0ebde3cd7f5ed120015006e0ea40bb4ddd Mon Sep 17 00:00:00 2001 From: Deon George Date: Thu, 23 May 2024 20:11:32 +1000 Subject: [PATCH] Dont record us in seenby/path for local messages. Update echomail display to know if an exchomail seenby has collected the message --- app/Models/Echomail.php | 7 ++-- resources/views/widgets/message.blade.php | 46 ++++++++++++++++------- 2 files changed, 36 insertions(+), 17 deletions(-) diff --git a/app/Models/Echomail.php b/app/Models/Echomail.php index 7f8dec9..e96f024 100644 --- a/app/Models/Echomail.php +++ b/app/Models/Echomail.php @@ -10,6 +10,7 @@ use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Log; use App\Casts\{CollectionOrNull,CompressedString}; +use App\Classes\FTN\Message; use App\Interfaces\Packet; use App\Traits\{MessageAttributes,MsgID,ParseAddresses,QueryCacheableConfig}; @@ -96,7 +97,6 @@ final class Echomail extends Model implements Packet throw new \Exception('Cannot save, validation errors exist'); }); - // @todo dont save us in the seenby/path, we'll add it dynamically when we send out. // @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(); @@ -110,7 +110,7 @@ final class Echomail extends Model implements Packet Log::debug(sprintf('%s:^ Message [%d] from point address is [%d]',self::LOGKEY,$model->id,$model->fftn->point_id)); // Make sure our sender is first in the path - if (! $path->contains($model->fftn_id)) { + if ((! $model->isFlagSet(Message::FLAG_LOCAL)) && (! $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); } @@ -141,7 +141,7 @@ final class Echomail extends Model implements Packet $seenby = self::parseAddresses('seenby',$model->set->get('set_seenby'),$model->fftn->zone,$rogue); // Make sure our sender is in the seenby - if (! $seenby->contains($model->fftn_id)) { + if ((! $model->isFlagSet(Message::FLAG_LOCAL)) && (! $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); } @@ -182,6 +182,7 @@ final class Echomail extends Model implements Packet ->addresses ->filter(function($item) use ($model) { return $model->echoarea->can_read($item->security); }) ->pluck('id') + ->diff(our_address($model->fftn->zone->domain)) ->diff($seenby); if ($exportto->count()) { diff --git a/resources/views/widgets/message.blade.php b/resources/views/widgets/message.blade.php index 3b08a5b..64cb1cf 100644 --- a/resources/views/widgets/message.blade.php +++ b/resources/views/widgets/message.blade.php @@ -63,7 +63,20 @@ use App\Models\{Echomail,Netmail}; @if ($msg instanceof Echomail)
- SEENBY:
{!! $msg->seenby->pluck('ftn2d')->join(', ') !!} + SEENBY:
{!! $msg + ->seenby + ->map(function($item) { + if ($item->pivot->export_at) { + if ($item->pivot->sent_at) + return sprintf('%s',$item->pivot->sent_at,$item->pivot->sent_pkt,$item->ftn2d); + else + return sprintf('%s',$item->ftn2d); + + } else { + return sprintf('%s',$item->ftn2d); + } + })->join(', ') !!} +
@if($msg->rogue_seenby->count()) @@ -72,10 +85,14 @@ use App\Models\{Echomail,Netmail};
@endif -
- PATH:
{!! $msg->pathorder()->join(' -> ') !!} + PATH: + @if($msg->path->count()) +
{!! $msg->pathorder()->join(' -> ') !!} + @else +
[No details] + @endif @if(($msg instanceof Echomail) && $msg->rogue_path->count())
[NOTE: Some path values couldnt be identified - ({{ $msg->rogue_path->join(',') }})] @@ -83,19 +100,20 @@ use App\Models\{Echomail,Netmail};
-
-
- @if($msg instanceof Netmail) +@if($msg->path->count()) +
+
RECEIVED:
- @foreach ($msg->path as $path) - {{ $path->pivot->recv_pkt }} from {{ $path->ftn }} {{ $msg->created_at }} - @endforeach - @elseif ($msg instanceof Echomail) - RECEIVED:
- {{ ($x=$msg->path->sortBy('pivot.parent_id')->last())->pivot->recv_pkt }} from {{ $x->ftn }} {{ $x->pivot->recv_at }} - @endif + @if($msg instanceof Netmail) + @foreach ($msg->path as $path) + {{ $path->pivot->recv_pkt }} from {{ $path->ftn }} {{ $msg->created_at }}
+ @endforeach + @elseif ($msg instanceof Echomail) + {{ ($x=$msg->path->sortBy('pivot.parent_id')->last())->pivot->recv_pkt }} from {{ $x->ftn }} {{ $x->pivot->recv_at }}
+ @endif +
-
+@endif @if($msg instanceof Netmail)