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();
$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;
foreach ($path as $aoid) {
$po = DB::select('INSERT INTO echomail_path (echomail_id,address_id,parent_id) VALUES (?,?,?) RETURNING id',[
$o->id,
$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?
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));
@ -355,7 +359,25 @@ class MessageProcess implements ShouldQueue
$o->datetime = $this->msg->date;
$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->msgid = $this->msg->msgid;
$o->replyid = $this->msg->replyid;
@ -363,6 +385,7 @@ class MessageProcess implements ShouldQueue
$o->msg = $this->msg->message_src."\r";
$o->msg_src = $this->msg->message_src;
$o->msg_crc = md5($this->msg->message);
$o->set_path = $this->msg->path;
$o->set_seenby = $this->msg->seenby;
$o->set_recvtime = $this->recvtime;

View File

@ -70,7 +70,7 @@ final class Echomail extends Model implements Packet
static::created(function($model) {
$rogue = collect();
$seenby = NULL;
$path = [];
$path = collect();
// Parse PATH
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
if (isset($model->set_pkt) && isset($model->set_recvtime)) {
DB::update('UPDATE echomail_path set recv_pkt=?,recv_at=? where address_id=? and echomail_id=?',[
$model->set_pkt,
$model->set_recvtime,
$path->last(),
$model->id,
]);
if ($path->count()) {
DB::update('UPDATE echomail_path set recv_pkt=?,recv_at=? where address_id=? and echomail_id=?',[
$model->set_pkt,
$model->set_recvtime,
$path->last(),
$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.