From 871430edf89a2138b299548dbff8d3288d5d80dc Mon Sep 17 00:00:00 2001 From: Deon George Date: Thu, 25 Nov 2021 21:22:36 +1100 Subject: [PATCH] Replace path from duplicate messages when the existing path is blank --- app/Classes/FTN/Packet.php | 2 +- app/Jobs/MessageProcess.php | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/Classes/FTN/Packet.php b/app/Classes/FTN/Packet.php index 886d7d3..da6f910 100644 --- a/app/Classes/FTN/Packet.php +++ b/app/Classes/FTN/Packet.php @@ -112,7 +112,7 @@ class Packet extends FTNBase implements \Iterator, \Countable * Open a packet file * * @param File $file - * @param Zone|null $zone + * @param System|null $system * @param bool $use_redis * @return Packet * @throws InvalidPacketException diff --git a/app/Jobs/MessageProcess.php b/app/Jobs/MessageProcess.php index 1329ea6..96e4a97 100644 --- a/app/Jobs/MessageProcess.php +++ b/app/Jobs/MessageProcess.php @@ -166,6 +166,14 @@ class MessageProcess implements ShouldQueue if (! $o->msg_crc) $o->msg_crc = md5($this->msg->message); + // Using filter here, due to earlier bugs - and to get rid of the null values + $o->path = collect($o->getRawOriginal('path'))->filter()->toArray(); + + // If the path is empty, then its probably because of the previous bug, we'll replace it. + // @todo This duplicate message may have gone via a different path, be nice to record it. + if (! $o->path->count()) + $o->path = collect($o->getRawOriginal('path'))->merge($this->msg->pathaddress)->toArray(); + $o->seenby = collect($o->getRawOriginal('seenby'))->merge($this->msg->seenaddress)->filter()->toArray(); $o->save();