From 84d9d271dc7be5a39beea26664791f524431a285 Mon Sep 17 00:00:00 2001 From: Deon George Date: Sun, 8 Sep 2024 14:14:37 +1000 Subject: [PATCH] Fix for not detecting duplicate messages, when messages had a TZUTC --- app/Jobs/MessageProcess.php | 57 +++++++++++-------------------------- 1 file changed, 17 insertions(+), 40 deletions(-) diff --git a/app/Jobs/MessageProcess.php b/app/Jobs/MessageProcess.php index 1ed6482..cb80c29 100644 --- a/app/Jobs/MessageProcess.php +++ b/app/Jobs/MessageProcess.php @@ -81,7 +81,7 @@ class MessageProcess implements ShouldQueue Log::debug(sprintf('%s:- Checking for duplicate from host [%s].',self::LOGKEY,$this->mo->fftn->ftn)); $o = Netmail::where('msgid',$this->mo->msgid) - ->where('fftn_id',$this->mo->fftn->id) + ->where('fftn_id',$this->mo->fftn_id) ->where('datetime','>',Carbon::now()->subYears(3)) ->single(); @@ -199,7 +199,7 @@ class MessageProcess implements ShouldQueue // The packet sender $sender = $this->mo->set->get('set_sender'); - // @todo Check that this does evaulate to true if a message has been rescanned + // @todo Check that this does evaluate to true if a message has been rescanned $rescanned = $this->mo->kludges->get('RESCANNED',FALSE); // Echoarea doesnt exist, cant import the message @@ -226,57 +226,34 @@ class MessageProcess implements ShouldQueue // Check for duplicate messages // FTS-0009.001 if ($this->mo->msgid) { - $o = Echomail::where('msgid',$this->mo->msgid) - ->where('fftn_id',$this->mo->fftn->id) - ->where('datetime','>=',$this->mo->date->clone()->subYears(3)) - ->where('datetime','<=',$this->mo->date) - ->dontCache() + $o = ($x=Echomail::where('msgid',$this->mo->msgid) + ->where('fftn_id',$this->mo->fftn_id) + ->where('datetime','>=',$this->mo->datetime->clone()->subYears(3)) + ->where('datetime','<=',$this->mo->datetime) + ->dontCache()) ->single(); - Log::debug(sprintf('%s:- Checking for duplicate from host id [%d].',self::LOGKEY,$this->mo->fftn->id)); + Log::debug(sprintf('%s:- Checking for duplicate from host id [%d], with msgid [%s] between [%s] and [%s].', + self::LOGKEY, + $this->mo->fftn_id, + $this->mo->msgid, + $this->mo->datetime->clone()->subYears(3), + $this->mo->datetime, + )); - if ($o) { + if ($x->count()) { // @todo Actually update seenby - Log::alert(sprintf('%s:! Duplicate echomail [%d] (%s) in [%s] from (%s) [%s] to (%s) - updating seenby.', + Log::alert(sprintf('%s:! Duplicate echomail (%s) in [%s] from (%s) [%s] to (%s) - ignoring.', self::LOGKEY, - $o->id, $this->mo->msgid, $this->mo->echoarea->name, $this->mo->from,$this->mo->fftn->ftn, $this->mo->to, )); - //$o->save(); - // @todo This duplicate message may have gone via a different path, be nice to record it. - - /* - // If we didnt get the path on the original message, we'll override it - if (! $o->path->count()) { - $dummy = collect(); - $path = $this->parseAddresses('path',$this->mo->path,$sender->zone,$dummy); - - $ppoid = NULL; - foreach ($path as $aoid) { - $po = DB::select('INSERT INTO echomail_path (echomail_id,address_id,parent_id) VALUES (?,?,?) RETURNING id',[ - $o->id, - $aoid, - $ppoid, - ]); - - $ppoid = $po[0]->id; - } - } - */ - // @todo if we have an export for any of the seenby addresses, remove it - //$seenby = $this->parseAddresses('seenby',$this->mo->seenby,$sender->zone,$o->rogue_seenby); - //$this->mo->seenby()->syncWithoutDetaching($seenby); - - // In case our rogue_seenby changed - //$this->mo->save(); - return; } } @@ -284,7 +261,7 @@ class MessageProcess implements ShouldQueue // Find another message with the same msg_crc if ($this->mo->msg_crc) { $o = Echomail::where('msg_crc',$xx=md5($this->mo->msg_crc)) - ->where('fftn_id',$this->mo->fftn->id) + ->where('fftn_id',$this->mo->fftn_id) ->where('datetime','>',Carbon::now()->subWeek()) ->dontCache() ->get();