Continue to show all common addresses in Items Waiting tab, Add Address Clear Queue job to delete anything in the queue for an address

This commit is contained in:
2024-11-04 15:58:20 +11:00
parent 80fa3e840b
commit 0bd2f6e82c
6 changed files with 146 additions and 37 deletions

View File

@@ -24,19 +24,28 @@ use App\Traits\{QueryCacheableConfig,ScopeActive};
*
* If an address is validated, we know that the system is using the address (we've confirmed that during a session).
* validated is update/removed is during a mailer session, confirming if the node has the address
* @todo Remove validated, if that system hasnt used the address for a defined period (eg: 30)
*
* We'll only trigger a poll to a system that we have mail for if active && validated, unless "forced".
*
* Any mail for that address will be delivered, if active && validated.
*
* Address status:
* + Active (active=true/validated=true) - mail can flow and in one of our networks (we have session details)
* + Pending (active=true/validated=false) - remote hasnt configured address during a session and in one of our networks
* + Known (active=true/validated=true) - the node presented this address, but we didnt auth it, and its a network we are not in
* + Unconfirm (active=true/validated=true) - the node presented this address, but we dont manage the address (it uses a different hub)
* + Nodelist (active=true/validated=true) - the node presented this address, but we dont manage the address and its in a recent nodelist
* + Delisted (active=false/validated=true) - this node shouldnt use this address any more
* + Freed (active=false/validated=false) - this node shouldnt is known to not be using this address any more
*
* Other Status
* + citizen - The address belongs to one of our jurisdiction (hub_id = our address, NC,RC,ZC)
* + foreign - The address doesnt belong to our jurisdiction
*
* @see \App\Http\Requests\AddressAdd::class for rules about AKA and role
*/
// Need to add
// Calculated Region for an FTN, ie: find the parent and use their region id
// - if creating an RC, then the region is part of the creation, ZC region is 0
// Then use this in createFTN
class Address extends Model
{
use QueryCacheableConfig,ScopeActive,SoftDeletes;
@@ -246,7 +255,7 @@ class Address extends Model
$o = self::findZone($do,$ftn['n'],$ftn['f'],$ftn['p'],$trashed);
}
return ($o && $o->system->active) ? $o : NULL;
return ($o && ($trashed || $o->system->active)) ? $o : NULL;
}
public static function newFTN(string $address): self
@@ -414,7 +423,7 @@ class Address extends Model
public function scopeFTN($query)
{
return $query
->select(['addresses.id','region_id','host_id','node_id','point_id','addresses.zone_id','addresses.active','role','security','addresses.system_id','addresses.active','validated'])
->select(['addresses.id','region_id','host_id','node_id','point_id','addresses.zone_id','addresses.active','role','security','addresses.system_id','addresses.active','validated','deleted_at'])
->join('zones',['zones.id'=>'addresses.zone_id'])
->join('domains',['domains.id'=>'zones.domain_id'])
->orderBy('domains.name')

View File

@@ -200,6 +200,14 @@ class System extends Model
/* METHODS */
public function addresses_common(): Collection
{
$our = our_address()->pluck('zone.domain_id')->unique();
// Return our akas, filter with our_addresses()
return $this->addresses->filter(fn($item)=>$our->contains($item->zone->domain_id));
}
/**
* Return the ACTIVE addresses that are common with our addresses
*