Remove Address::downstream() for Address::downlinks()

This commit is contained in:
Deon George 2024-11-25 23:24:21 +11:00
parent 9c828d65e6
commit 1296e3be40
3 changed files with 19 additions and 32 deletions

View File

@ -24,7 +24,7 @@ class AddressCheck extends Command
$this->info(sprintf('Address: %s (%s)',$o->ftn,$o->role_name)); $this->info(sprintf('Address: %s (%s)',$o->ftn,$o->role_name));
$this->info(sprintf("Children: \n- %s",$o->children()->pluck('ftn4d')->join("\n- "))); $this->info(sprintf("Children: \n- %s",$o->children()->pluck('ftn4d')->join("\n- ")));
$this->info(sprintf("Downstream: \n- %s",$o->downstream()->pluck('ftn4d')->join("\n- "))); $this->info(sprintf("Downlinks: \n- %s",$o->downlinks()->pluck('ftn4d')->join("\n- ")));
$this->info(sprintf('Uplink: %s (Parent: %s)',$o->uplink()?->ftn,$o->parent()?->ftn)); $this->info(sprintf('Uplink: %s (Parent: %s)',$o->uplink()?->ftn,$o->parent()?->ftn));
$this->info(sprintf('Our Address: %s',our_address($o)?->ftn)); $this->info(sprintf('Our Address: %s',our_address($o)?->ftn));
$this->info(sprintf('- Domain Addresses: %s',our_address($o->zone->domain)->pluck('ftn4d')->join(','))); $this->info(sprintf('- Domain Addresses: %s',our_address($o->zone->domain)->pluck('ftn4d')->join(',')));

View File

@ -25,21 +25,22 @@ class ZoneCheck extends Command
$this->warn('Zone: '.$zo->zone_id); $this->warn('Zone: '.$zo->zone_id);
$this->info(sprintf('- Our address(es): %s',our_address($do)->pluck('ftn4d')->join(','))); $this->info(sprintf('- Our address(es): %s',our_address($do)->pluck('ftn4d')->join(',')));
$this->table(['id','ftn','role','parent','children','downlinks','uplink','send from','region_id','system','notes'],$zo->addresses()->FTNorder()->active()->with(['system'])->get()->transform(function($item) { $this->table(['id','ftn','role','parent','children','downlinks','uplink','send from','region_id','system','notes'],
return [ $zo->addresses()->FTN()->active()->with(['system','nodes_hub'])->get()->transform(function($item) {
'id'=>$item->id, return [
'ftn'=>$item->ftn4d, 'id'=>$item->id,
'role'=>$item->role_name, 'ftn'=>$item->ftn4d,
'parent'=>$item->parent()?->ftn4d, 'role'=>$item->role_name,
'children'=>$item->children()->count(), 'parent'=>$item->parent()?->ftn4d,
'downlinks'=>$item->downlinks()->count(), 'children'=>$item->children()->count(),
'uplink'=>($x=$item->uplink())?->ftn4d, 'downlinks'=>$item->downlinks()->count(),
'send from'=>$x ? our_address($item->uplink())?->ftn4d : '', 'uplink'=>($x=$item->uplink())?->ftn4d,
'region_id'=>$item->region_id, 'send from'=>$x ? our_address($item->uplink())?->ftn4d : '',
'system'=>$item->system->name, 'region_id'=>$item->region_id,
'notes'=>$item->isRoleOverride() ? 'Role Override' : '', 'system'=>$item->system->name,
]; 'notes'=>$item->isRoleOverride() ? 'Role Override' : '',
})); ];
}));
} }
return self::SUCCESS; return self::SUCCESS;

View File

@ -1062,20 +1062,6 @@ class Address extends Model
return $children->diff($exclude); return $children->diff($exclude);
} }
/**
* List of all our nodes and their children
*
* @return \Illuminate\Support\Collection
* @throws \Exception
* @deprecated use children()
*/
public function downstream(): \Illuminate\Support\Collection
{
return $this->downlinks()->transform(function($item) {
return $item->nodes()->push($item);
})->flatten();
}
/** /**
* Files waiting to be sent to this system * Files waiting to be sent to this system
* *
@ -1266,8 +1252,8 @@ class Address extends Model
// Addresses that our downstream of this address, except anybody that has session details with us // Addresses that our downstream of this address, except anybody that has session details with us
$ours = our_nodes($this->zone->domain)->pluck('id'); $ours = our_nodes($this->zone->domain)->pluck('id');
$addresses = $this->downstream() $addresses = $this->downlinks()
->filter(fn($item)=>! $ours->contains($item->id)) ->filter(fn($item)=>(! $ours->contains($item->id)))
->merge($this->system->match($this->zone,Address::NODE_ALL)); ->merge($this->system->match($this->zone,Address::NODE_ALL));
$netmails = $this $netmails = $this