Compare commits

...

3 Commits

Author SHA1 Message Date
4f8448563d Fix for when adding our address to path for outgoing echomails - introduced in 5fc6906
All checks were successful
Create Docker Image / Build Docker Image (x86_64) (push) Successful in 41s
Create Docker Image / Build Docker Image (arm64) (push) Successful in 1m46s
Create Docker Image / Final Docker Image Manifest (push) Successful in 10s
2024-05-23 17:38:18 +10:00
710adad634 Show only validated addresses with packets for packet:system 2024-05-23 17:37:46 +10:00
5fc69067fb Fix sorting of seenby/path items in echomail/netmail. Add rogue_seenby to seenby in echomail 2024-05-23 17:37:46 +10:00
7 changed files with 64 additions and 14 deletions

View File

@ -152,6 +152,7 @@ class Message extends FTNBase
* *
* @param Echomail|Netmail $o * @param Echomail|Netmail $o
* @return self * @return self
* @throws \Exception
*/ */
public static function packMessage(Echomail|Netmail $o): self public static function packMessage(Echomail|Netmail $o): self
{ {
@ -571,11 +572,28 @@ class Message extends FTNBase
} else { } else {
// FTS-0004.001/FSC-0068.001 The message SEEN-BY lines // FTS-0004.001/FSC-0068.001 The message SEEN-BY lines
// FTS-0004.001/FSC-0068.001 The message PATH lines // FTS-0004.001/FSC-0068.001 The message PATH lines
// @todo we need to include our rogue_seenbys
// @todo make sure a point is NOT in the seenby/path when exporting // @todo This unique() function here shouldnt be required, but is while system generated messages are storing path/seenby
// @todo automatically include our address in the seenby/path $path = $this->mo->path->push($this->us)->unique('ftn')->filter(fn($item)=>($item->point_id === 0));
$return .= $this->aka_trim($this->mo->seenby,'SEEN-BY:')."\r";
$return .= "\x01".$this->aka_trim($this->mo->path,'PATH:')."\r"; // Create our rogue seenby objects
$seenby = $this->mo->seenby;
if ($this->mo->rogue_seenby->count()) {
$do = $this->mo->echoarea->domain;
foreach ($this->mo->rogue_seenby as $item)
$seenby->push(Address::newFTN(sprintf('%s@%s',$item,$do->name)));
}
$seenby = $seenby
->push($this->us)
->filter(fn($item)=>($item->point_id === 0))
->unique('ftn')
->sortBy(function($item) { return sprintf('%05d%05d',$item->host_id,$item->node_id);});
$return .= $this->aka_trim($seenby,'SEEN-BY:')."\r";
$return .= "\x01".$this->aka_trim($path,'PATH:')."\r";
} }
$return .= "\00"; $return .= "\00";

View File

@ -16,6 +16,7 @@ final class Mail extends Send
/** @var int Our internal position counter */ /** @var int Our internal position counter */
private int $readpos; private int $readpos;
private ?string $content;
/** /**
* @throws \Exception * @throws \Exception
@ -84,6 +85,8 @@ final class Mail extends Send
'sent_at'=>Carbon::now(), 'sent_at'=>Carbon::now(),
'sent_pkt'=>$this->name, 'sent_pkt'=>$this->name,
]); ]);
$this->content = NULL;
} }
} }
@ -94,12 +97,13 @@ final class Mail extends Send
public function open(string $compress=''): bool public function open(string $compress=''): bool
{ {
$this->content = (string)$this->f;
return TRUE; return TRUE;
} }
public function read(int $length): string public function read(int $length): string
{ {
$result = substr((string)$this->f,$this->readpos,$length); $result = substr($this->content,$this->readpos,$length);
$this->readpos += strlen($result); $this->readpos += strlen($result);
return $result; return $result;
@ -108,7 +112,7 @@ final class Mail extends Send
public function seek(int $pos): bool public function seek(int $pos): bool
{ {
$this->readpos = ($pos < $this->size) ? $pos : $this->size; $this->readpos = ($pos < $this->size) ? $pos : $this->size;
return TRUE; return TRUE;
} }
private function youngest(): Carbon private function youngest(): Carbon

View File

@ -26,21 +26,31 @@ class PacketSystem extends Command
/** /**
* Execute the console command. * Execute the console command.
* *
* @return mixed * @return int
* @throws \App\Exceptions\InvalidPacketException * @throws \Exception
*/ */
public function handle() public function handle()
{ {
$ao = Address::findFTN($this->argument('ftn')); $ao = Address::findFTN($this->argument('ftn'));
foreach ($ao->system->addresses as $o) { foreach ($ao->system->addresses->where('validated',TRUE) as $o) {
$pkt = $o->getEchomail(); $pkt = $o->getEchomail();
$this->info(sprintf('System address [%s] has [%d] messages.',$ao->ftn,$pkt?->count())); $this->info(sprintf('System address [%s] has [%d] echomail messages.',$o->ftn,$pkt?->count()));
if ($pkt) {
foreach ($pkt as $msg)
$this->warn(sprintf('- %s (%s)',$msg->msgid,$msg->id));
}
$pkt = $o->getNetmail();
$this->info(sprintf('System address [%s] has [%d] netmail messages.',$o->ftn,$pkt?->count()));
if ($pkt) { if ($pkt) {
foreach ($pkt as $msg) foreach ($pkt as $msg)
$this->warn(sprintf('- %s (%s)',$msg->msgid,$msg->id)); $this->warn(sprintf('- %s (%s)',$msg->msgid,$msg->id));
} }
} }
return self::SUCCESS;
} }
} }

View File

@ -242,6 +242,22 @@ class Address extends Model
return ($o && $o->system->active) ? $o : NULL; return ($o && $o->system->active) ? $o : NULL;
} }
public static function newFTN(string $address): self
{
$ftn = self::parseFTN($address);
$o = new self;
$zo = Zone::where('zone_id',$ftn['z'])->single();
$o->zone_id = $zo?->id;
$o->region_id = $ftn['r'];
$o->host_id = $ftn['n'];
$o->node_id = $ftn['f'];
$o->point_id = $ftn['p'];
return $o;
}
/** /**
* This is to find an address for a domain (like fidonet), which is technically 2D even though it uses multiple zones. * This is to find an address for a domain (like fidonet), which is technically 2D even though it uses multiple zones.
* *
@ -324,7 +340,7 @@ class Address extends Model
$zone_id = $parent?->zone->zone_id; $zone_id = $parent?->zone->zone_id;
// For flattened domains // For flattened domains
if ($zo->domain->flatten && is_null($zone_id)) if ($zo?->domain->flatten && is_null($zone_id))
foreach ($zo->domain->zones as $zoo) { foreach ($zo->domain->zones as $zoo) {
$o->zone_id = $zoo->id; $o->zone_id = $zoo->id;
$parent = $o->parent(); $parent = $o->parent();

View File

@ -222,7 +222,8 @@ final class Echomail extends Model implements Packet
public function path() public function path()
{ {
return $this->belongsToMany(Address::class,'echomail_path') return $this->belongsToMany(Address::class,'echomail_path')
->withPivot(['id','parent_id','recv_pkt','recv_at']); ->withPivot(['id','parent_id','recv_pkt','recv_at'])
->orderBy('id','DESC');
} }
/* ATTRIBUTES */ /* ATTRIBUTES */

View File

@ -179,6 +179,7 @@ final class Netmail extends Model implements Packet
{ {
return $this->belongsToMany(Address::class,'netmail_path') return $this->belongsToMany(Address::class,'netmail_path')
->withPivot(['id','parent_id','datetime','program','recv_pkt','recv_id']) ->withPivot(['id','parent_id','datetime','program','recv_pkt','recv_id'])
->orderBy('netmail_path.id')
->using(ViaPivot::class); ->using(ViaPivot::class);
} }

View File

@ -167,7 +167,7 @@ trait MessageAttributes
*/ */
public function packet(Address $ao): Message public function packet(Address $ao): Message
{ {
Log::debug(sprintf('%s:+ Bundling [%s]',self::LOGKEY,$this->id),['type'=>get_class($this)]); Log::debug(sprintf('%s:+ Bundling [%s] for [%s]',self::LOGKEY,$this->id,$ao->ftn),['type'=>get_class($this)]);
// For netmails, our tftn is the next hop // For netmails, our tftn is the next hop
$this->tftn = $ao; $this->tftn = $ao;