Improvements to echomail path handling, ensuring sender and pktsrc are in the path

This commit is contained in:
Deon George 2023-11-17 12:18:55 +11:00
parent 67747c062a
commit 4a870b6587
2 changed files with 38 additions and 10 deletions

View File

@ -287,9 +287,14 @@ class MessageProcess implements ShouldQueue
$dummy = collect(); $dummy = collect();
$path = $this->parseAddresses('path',$this->msg->path,$this->pktsrc->zone,$dummy); $path = $this->parseAddresses('path',$this->msg->path,$this->pktsrc->zone,$dummy);
// If our sender is not in the path, add it
if (! $path->contains($this->sender->id)) {
Log::alert(sprintf('%s:? Echomail adding sender to PATH [%s] for [%d].',self::LOGKEY,$x->ftn,$o->id));
$path->push($this->sender->id);
}
$ppoid = NULL; $ppoid = NULL;
foreach ($path as $aoid) { foreach ($path as $aoid) {
$po = DB::select('INSERT INTO echomail_path (echomail_id,address_id,parent_id) VALUES (?,?,?) RETURNING id',[ $po = DB::select('INSERT INTO echomail_path (echomail_id,address_id,parent_id) VALUES (?,?,?) RETURNING id',[
$o->id, $o->id,
$aoid, $aoid,
@ -327,7 +332,6 @@ class MessageProcess implements ShouldQueue
)); ));
} }
// @todo Can the sender create it if it doesnt exist?
// Can the system send messages to this area? // Can the system send messages to this area?
if (! $ea->sec_write || ($this->pktsrc->security < $ea->sec_write)) { if (! $ea->sec_write || ($this->pktsrc->security < $ea->sec_write)) {
Log::alert(sprintf('%s:! FTN [%s] is not allowed to post [%s] to [%s].',self::LOGKEY,$this->pktsrc->ftn,$this->msg->msgid,$ea->name)); Log::alert(sprintf('%s:! FTN [%s] is not allowed to post [%s] to [%s].',self::LOGKEY,$this->pktsrc->ftn,$this->msg->msgid,$ea->name));
@ -355,7 +359,25 @@ class MessageProcess implements ShouldQueue
$o->datetime = $this->msg->date; $o->datetime = $this->msg->date;
$o->tzoffset = $this->msg->date->utcOffset(); $o->tzoffset = $this->msg->date->utcOffset();
$o->fftn_id = ($x=$this->msg->fboss_o) ? $x->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 ($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->echoarea_id = $ea->id;
$o->msgid = $this->msg->msgid; $o->msgid = $this->msg->msgid;
$o->replyid = $this->msg->replyid; $o->replyid = $this->msg->replyid;
@ -363,6 +385,7 @@ class MessageProcess implements ShouldQueue
$o->msg = $this->msg->message_src."\r"; $o->msg = $this->msg->message_src."\r";
$o->msg_src = $this->msg->message_src; $o->msg_src = $this->msg->message_src;
$o->msg_crc = md5($this->msg->message); $o->msg_crc = md5($this->msg->message);
$o->set_path = $this->msg->path; $o->set_path = $this->msg->path;
$o->set_seenby = $this->msg->seenby; $o->set_seenby = $this->msg->seenby;
$o->set_recvtime = $this->recvtime; $o->set_recvtime = $this->recvtime;

View File

@ -70,7 +70,7 @@ final class Echomail extends Model implements Packet
static::created(function($model) { static::created(function($model) {
$rogue = collect(); $rogue = collect();
$seenby = NULL; $seenby = NULL;
$path = []; $path = collect();
// Parse PATH // Parse PATH
if ($model->set_path->count()) if ($model->set_path->count())
@ -104,12 +104,17 @@ final class Echomail extends Model implements Packet
// Our last node in the path is our sender // Our last node in the path is our sender
if (isset($model->set_pkt) && isset($model->set_recvtime)) { if (isset($model->set_pkt) && isset($model->set_recvtime)) {
if ($path->count()) {
DB::update('UPDATE echomail_path set recv_pkt=?,recv_at=? where address_id=? and echomail_id=?',[ DB::update('UPDATE echomail_path set recv_pkt=?,recv_at=? where address_id=? and echomail_id=?',[
$model->set_pkt, $model->set_pkt,
$model->set_recvtime, $model->set_recvtime,
$path->last(), $path->last(),
$model->id, $model->id,
]); ]);
} else {
Log::critical(sprintf('%s:! Wasnt able to set packet details for [%d] to [%s] to [%s], no path information',self::LOGKEY,$model->id,$model->set_pkt,$model->set_recvtime));
}
} }
// See if we need to export this message. // See if we need to export this message.