An enhancement to ensure that flatten domains gets the correct FTN
This commit is contained in:
parent
a991db788e
commit
6e133770fc
@ -704,7 +704,7 @@ class Message extends FTNBase
|
||||
|
||||
// If domain should be flattened, look for node regardless of zone (within the list of zones for the domain)
|
||||
if ($this->fdomain && $this->fdomain->flatten) {
|
||||
$ao = Address::findZone($this->fdomain,$net&DomainController::NUMBER_MAX,$node&DomainController::NUMBER_MAX);
|
||||
$ao = Address::findZone($this->fdomain,$net&DomainController::NUMBER_MAX,$node&DomainController::NUMBER_MAX,0);
|
||||
|
||||
$aoid = $ao?->id;
|
||||
|
||||
|
@ -419,6 +419,7 @@ class Address extends Model
|
||||
return $o;
|
||||
}
|
||||
|
||||
// Look for a normal address
|
||||
$o = ($x=(new self)
|
||||
->select('addresses.*')
|
||||
->join('zones',['zones.id'=>'addresses.zone_id'])
|
||||
@ -450,6 +451,26 @@ class Address extends Model
|
||||
}))
|
||||
->single();
|
||||
|
||||
if ($o && $o->system->active)
|
||||
return $o;
|
||||
|
||||
// Check and see if we are a flattened domain, our address might be available with a different zone.
|
||||
if ($ftn['p'] === 0) {
|
||||
if ($ftn['d'])
|
||||
$do = Domain::where(['name'=>$ftn['d']])->single();
|
||||
else {
|
||||
$zo = Zone::where('zone_id',$ftn['z'])->where('default',TRUE)->single();
|
||||
$do = $zo?->domain;
|
||||
}
|
||||
|
||||
if ($do && $do->flatten) {
|
||||
$o = self::findZone($do,$ftn['n'],$ftn['f'],$ftn['p'],$trashed);
|
||||
|
||||
if ($o && $o->system->active)
|
||||
return $o;
|
||||
}
|
||||
}
|
||||
|
||||
if ($create) {
|
||||
if (! $so)
|
||||
throw new \Exception(sprintf('%s:AKA create requested for [%s], but system not provided',self::LOGKEY,$address));
|
||||
@ -525,7 +546,7 @@ class Address extends Model
|
||||
* @return self|null
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function findZone(Domain $do,int $host,int $node,bool $trashed=FALSE): ?self
|
||||
public static function findZone(Domain $do,int $host,int $node,int $point,bool $trashed=FALSE): ?self
|
||||
{
|
||||
if (! $do->flatten)
|
||||
throw new \Exception(sprintf('Domain is not set with flatten: %d',$do->id));
|
||||
@ -550,6 +571,7 @@ class Address extends Model
|
||||
->orWhere('host_id',$host);
|
||||
})
|
||||
->where('node_id',$node)
|
||||
->where('point_id',$point)
|
||||
->where('zones.domain_id',$do->id)
|
||||
->single();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user