When we have multiple addresses, add we want a specific address, return the lowest role, or if strict mode enable, return the lowest role that is higher than the target
This commit is contained in:
@@ -85,16 +85,24 @@ if (! function_exists('hexstr')) {
|
||||
* Return our addresses.
|
||||
* If zone provided, limit the list to those within the zone
|
||||
*
|
||||
* @param Domain|NULL $do
|
||||
* @return Collection
|
||||
* @param Domain|NULL $do Limit the addresses for the specific domain
|
||||
* @param Address|null $ao If address is presented, show the address we use when talking to that address
|
||||
* @return Collection|Address|NULL
|
||||
*/
|
||||
function our_address(Domain $do=NULL): Collection
|
||||
function our_address(Domain $do=NULL,Address $ao=NULL): Collection|Address|NULL
|
||||
{
|
||||
$our = Setup::findOrFail(config('app.id'))->system->addresses;
|
||||
$our = Setup::findOrFail(config('app.id'))
|
||||
->system
|
||||
->akas;
|
||||
|
||||
return $do
|
||||
? $our->filter(function($item) use ($do) { return $item->zone->domain_id === $do->id; })
|
||||
: $our;
|
||||
if ($do)
|
||||
$our = $our->filter(function($item) use ($do) { return $item->zone->domain_id === $do->id; });
|
||||
|
||||
// If we are looking for a specific address, and there is only 1 result, return it, otherwise return what we have
|
||||
if ($ao && config('fido.strict') && ($x=$our->filter(function($item) use ($ao) { return $item->role <= $ao->role; }))->count())
|
||||
$our = $x;
|
||||
|
||||
return $ao ? $our->last() : $our;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user