Complete of logging received and sent packet names, and display them in the web ui for each node
This commit is contained in:
@@ -22,7 +22,7 @@ final class Echomail extends Model implements Packet
|
||||
private const LOGKEY = 'ME-';
|
||||
private Collection $set_seenby;
|
||||
private Collection $set_path;
|
||||
private ?string $set_packet = NULL;
|
||||
private string $set_pkt;
|
||||
private bool $no_export = FALSE;
|
||||
|
||||
protected $casts = [
|
||||
@@ -50,7 +50,7 @@ final class Echomail extends Model implements Packet
|
||||
switch ($key) {
|
||||
case 'no_export':
|
||||
case 'set_path':
|
||||
case 'set_packet':
|
||||
case 'set_pkt':
|
||||
case 'set_seenby':
|
||||
$this->{$key} = $value;
|
||||
break;
|
||||
@@ -71,17 +71,8 @@ final class Echomail extends Model implements Packet
|
||||
return;
|
||||
}
|
||||
|
||||
// Our address
|
||||
$ftns = Setup::findOrFail(config('app.id'))
|
||||
->system
|
||||
->match($model->fftn->zone);
|
||||
|
||||
// Add our address to the seenby;
|
||||
$model->set_seenby = $model->set_seenby->merge($ftns->pluck('id'))->unique();
|
||||
$model->set_path = $model->set_path->merge($ftns->pluck('id'));
|
||||
|
||||
// Save the seenby
|
||||
$model->seenby()->syncWithPivotValues($model->set_seenby,['packet'=>$model->set_packet]);
|
||||
$model->seenby()->sync($model->set_seenby);
|
||||
|
||||
// Save the Path
|
||||
$ppoid = NULL;
|
||||
@@ -95,6 +86,15 @@ final class Echomail extends Model implements Packet
|
||||
$ppoid = $po[0]->id;
|
||||
}
|
||||
|
||||
// Our last node in the path is our sender
|
||||
if (isset($model->set_pkt)) {
|
||||
DB::update('UPDATE echomail_path set recv_pkt=? where address_id=? and echomail_id=?',[
|
||||
$model->set_pkt,
|
||||
$model->set_path->last(),
|
||||
$model->id,
|
||||
]);
|
||||
}
|
||||
|
||||
// See if we need to export this message.
|
||||
$exportto = $model->echoarea->addresses->pluck('id')->diff($model->set_seenby);
|
||||
|
||||
@@ -143,7 +143,6 @@ final class Echomail extends Model implements Packet
|
||||
{
|
||||
$this->set_path = collect();
|
||||
$this->set_seenby = collect();
|
||||
$this->set_packet = NULL;
|
||||
}
|
||||
|
||||
public function jsonSerialize(): array
|
||||
@@ -156,7 +155,7 @@ final class Echomail extends Model implements Packet
|
||||
*/
|
||||
public function packet(Address $ao): Message
|
||||
{
|
||||
Log::debug(sprintf('%s:Bundling [%s]',self::LOGKEY,$this->id));
|
||||
Log::debug(sprintf('%s:+ Bundling [%s]',self::LOGKEY,$this->id));
|
||||
|
||||
// @todo Dont bundle mail to nodes that have been disabled, or addresses that have been deleted
|
||||
$o = new Message;
|
||||
@@ -166,7 +165,7 @@ final class Echomail extends Model implements Packet
|
||||
'dnode' => $ao->node_id,
|
||||
'onet' => $this->fftn->host_id,
|
||||
'dnet' => $ao->host_id,
|
||||
'flags' => 0, // @todo?
|
||||
'flags' => 0,
|
||||
'cost' => 0,
|
||||
'date'=>$this->datetime->format('d M y H:i:s'),
|
||||
];
|
||||
@@ -198,8 +197,11 @@ final class Echomail extends Model implements Packet
|
||||
if ($this->origin)
|
||||
$o->origin = $this->origin;
|
||||
|
||||
$o->seenby = $this->seenby->pluck('ftn2d');
|
||||
$o->path = $this->pathorder();
|
||||
$sysaddress = Setup::findOrFail(config('app.id'))->system->match($this->fftn->zone)->first();
|
||||
$o->seenby = $this->seenby->push($sysaddress)->unique()->pluck('ftn2d');
|
||||
|
||||
// Add our address to the path and seenby
|
||||
$o->path = $this->pathorder()->merge($sysaddress->ftn2d);
|
||||
|
||||
$o->packed = TRUE;
|
||||
|
||||
|
Reference in New Issue
Block a user