Fix for not detecting duplicate messages, when messages had a TZUTC

This commit is contained in:
Deon George 2024-09-08 14:14:37 +10:00
parent 61dfadba5a
commit 84d9d271dc

View File

@ -81,7 +81,7 @@ class MessageProcess implements ShouldQueue
Log::debug(sprintf('%s:- Checking for duplicate from host [%s].',self::LOGKEY,$this->mo->fftn->ftn)); Log::debug(sprintf('%s:- Checking for duplicate from host [%s].',self::LOGKEY,$this->mo->fftn->ftn));
$o = Netmail::where('msgid',$this->mo->msgid) $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)) ->where('datetime','>',Carbon::now()->subYears(3))
->single(); ->single();
@ -199,7 +199,7 @@ class MessageProcess implements ShouldQueue
// The packet sender // The packet sender
$sender = $this->mo->set->get('set_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); $rescanned = $this->mo->kludges->get('RESCANNED',FALSE);
// Echoarea doesnt exist, cant import the message // Echoarea doesnt exist, cant import the message
@ -226,57 +226,34 @@ class MessageProcess implements ShouldQueue
// Check for duplicate messages // Check for duplicate messages
// FTS-0009.001 // FTS-0009.001
if ($this->mo->msgid) { if ($this->mo->msgid) {
$o = Echomail::where('msgid',$this->mo->msgid) $o = ($x=Echomail::where('msgid',$this->mo->msgid)
->where('fftn_id',$this->mo->fftn->id) ->where('fftn_id',$this->mo->fftn_id)
->where('datetime','>=',$this->mo->date->clone()->subYears(3)) ->where('datetime','>=',$this->mo->datetime->clone()->subYears(3))
->where('datetime','<=',$this->mo->date) ->where('datetime','<=',$this->mo->datetime)
->dontCache() ->dontCache())
->single(); ->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 // @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, self::LOGKEY,
$o->id,
$this->mo->msgid, $this->mo->msgid,
$this->mo->echoarea->name, $this->mo->echoarea->name,
$this->mo->from,$this->mo->fftn->ftn, $this->mo->from,$this->mo->fftn->ftn,
$this->mo->to, $this->mo->to,
)); ));
//$o->save();
// @todo This duplicate message may have gone via a different path, be nice to record it. // @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 // @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; return;
} }
} }
@ -284,7 +261,7 @@ class MessageProcess implements ShouldQueue
// Find another message with the same msg_crc // Find another message with the same msg_crc
if ($this->mo->msg_crc) { if ($this->mo->msg_crc) {
$o = Echomail::where('msg_crc',$xx=md5($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()) ->where('datetime','>',Carbon::now()->subWeek())
->dontCache() ->dontCache()
->get(); ->get();