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

This commit is contained in:
Deon George 2024-11-25 23:24:21 +11:00
parent bc3407e9d4
commit 7a7d7b369e
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("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('Our Address: %s',our_address($o)?->ftn));
$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->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) {
return [
'id'=>$item->id,
'ftn'=>$item->ftn4d,
'role'=>$item->role_name,
'parent'=>$item->parent()?->ftn4d,
'children'=>$item->children()->count(),
'downlinks'=>$item->downlinks()->count(),
'uplink'=>($x=$item->uplink())?->ftn4d,
'send from'=>$x ? our_address($item->uplink())?->ftn4d : '',
'region_id'=>$item->region_id,
'system'=>$item->system->name,
'notes'=>$item->isRoleOverride() ? 'Role Override' : '',
];
}));
$this->table(['id','ftn','role','parent','children','downlinks','uplink','send from','region_id','system','notes'],
$zo->addresses()->FTN()->active()->with(['system','nodes_hub'])->get()->transform(function($item) {
return [
'id'=>$item->id,
'ftn'=>$item->ftn4d,
'role'=>$item->role_name,
'parent'=>$item->parent()?->ftn4d,
'children'=>$item->children()->count(),
'downlinks'=>$item->downlinks()->count(),
'uplink'=>($x=$item->uplink())?->ftn4d,
'send from'=>$x ? our_address($item->uplink())?->ftn4d : '',
'region_id'=>$item->region_id,
'system'=>$item->system->name,
'notes'=>$item->isRoleOverride() ? 'Role Override' : '',
];
}));
}
return self::SUCCESS;

View File

@ -1062,20 +1062,6 @@ class Address extends Model
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
*
@ -1266,8 +1252,8 @@ class Address extends Model
// Addresses that our downstream of this address, except anybody that has session details with us
$ours = our_nodes($this->zone->domain)->pluck('id');
$addresses = $this->downstream()
->filter(fn($item)=>! $ours->contains($item->id))
$addresses = $this->downlinks()
->filter(fn($item)=>(! $ours->contains($item->id)))
->merge($this->system->match($this->zone,Address::NODE_ALL));
$netmails = $this