diff --git a/app/Classes/FTN/Tic.php b/app/Classes/FTN/Tic.php index 0931887..1cdcb37 100644 --- a/app/Classes/FTN/Tic.php +++ b/app/Classes/FTN/Tic.php @@ -90,7 +90,7 @@ class Tic extends FTNBase if (! $this->to) throw new \Exception('No to address defined'); - $sysaddress = ($x=Setup::findOrFail(config('app.id'))->system)->match($this->to->zone)->first(); + $sysaddress = our_address($this->to->zone->domain,$this->to); $result = collect(); @@ -233,7 +233,7 @@ class Tic extends FTNBase // This should be one of my addresses case 'to': - $ftns = Setup::findOrFail(config('app.id'))->system->addresses->pluck('ftn3d'); + $ftns = our_address()->pluck('ftn3d'); if (! ($ftns->contains($m[2]))) throw new NotToMeException(sprintf('FTN Address [%s] not found or not one of my addresses',$m[2])); diff --git a/app/Classes/Protocol.php b/app/Classes/Protocol.php index 1574497..506a184 100644 --- a/app/Classes/Protocol.php +++ b/app/Classes/Protocol.php @@ -307,14 +307,14 @@ abstract class Protocol $addresses = collect(); foreach (($this->originate ? $this->node->aka_remote_authed : $this->node->aka_remote) as $ao) - $addresses = $addresses->merge($this->setup->system->match($ao->zone,Address::NODE_ZC|Address::NODE_RC|Address::NODE_NC|Address::NODE_HC|Address::NODE_ACTIVE|Address::NODE_PVT|Address::NODE_POINT)); + $addresses = $addresses->merge(our_address($ao->zone->domain)); $addresses = $addresses->unique(); Log::debug(sprintf('%s:- Presenting limited AKAs [%s]',self::LOGKEY,$addresses->pluck('ftn')->join(','))); } else { - $addresses = $this->setup->system->addresses; + $addresses = $this->setup->system->akas; Log::debug(sprintf('%s:- Presenting ALL our AKAs [%s]',self::LOGKEY,$addresses->pluck('ftn')->join(','))); } diff --git a/app/Http/Controllers/SystemController.php b/app/Http/Controllers/SystemController.php index 69993d7..1e1c1b1 100644 --- a/app/Http/Controllers/SystemController.php +++ b/app/Http/Controllers/SystemController.php @@ -833,12 +833,11 @@ class SystemController extends Controller if (! $request->system_id) return redirect('user/system/register'); - $s = Setup::findOrFail(config('app.id'))->system; $so = System::findOrFail($request->system_id); $ca = NULL; $la = NULL; - foreach ($s->akas as $ao) { + foreach (our_address() as $ao) { if (($ca=$so->match($ao->zone))->count()) break; } diff --git a/app/Http/Requests/AreafixRequest.php b/app/Http/Requests/AreafixRequest.php index bea18fd..35b0eca 100644 --- a/app/Http/Requests/AreafixRequest.php +++ b/app/Http/Requests/AreafixRequest.php @@ -27,7 +27,7 @@ class AreafixRequest extends FormRequest ], 'fftn_id' => [ 'required', - Rule::in(Setup::findOrFail(config('app.id'))->system->akas->pluck('id')), + Rule::in(our_address()->pluck('id')), ], 'tftn_id' => [ 'required', diff --git a/app/Jobs/MessageProcess.php b/app/Jobs/MessageProcess.php index 77e95a2..fd519db 100644 --- a/app/Jobs/MessageProcess.php +++ b/app/Jobs/MessageProcess.php @@ -58,7 +58,7 @@ class MessageProcess implements ShouldQueue public function handle() { // Load our details - $ftns = Setup::findOrFail(config('app.id'))->system->addresses; + $ftns = our_address(); // If we are a netmail if ($this->msg->isNetmail()) { diff --git a/app/Jobs/NodelistImport.php b/app/Jobs/NodelistImport.php index 3852857..e2bd058 100644 --- a/app/Jobs/NodelistImport.php +++ b/app/Jobs/NodelistImport.php @@ -74,7 +74,6 @@ class NodelistImport implements ShouldQueue */ public function handle() { - $us = Setup::findOrFail(config('app.id')); $our_systems = SystemZone::select('system_id') ->get() ->pluck('system') @@ -94,7 +93,7 @@ class NodelistImport implements ShouldQueue ->pluck('id') ->diff($our_systems); - $our_addresses = $us->system->addresses->pluck('id'); + $our_addresses = our_address()->pluck('id'); // Get the file from the host $file = $this->getFileFromHost(self::importkey,$this->file); diff --git a/app/Jobs/SystemHeartbeat.php b/app/Jobs/SystemHeartbeat.php index b3ba088..a970d65 100644 --- a/app/Jobs/SystemHeartbeat.php +++ b/app/Jobs/SystemHeartbeat.php @@ -26,7 +26,7 @@ class SystemHeartbeat #implements ShouldQueue public function handle(): void { // Our zones - $our_zones = Setup::findOrFail(config('app.id'))->system->addresses->pluck('zone_id')->unique(); + $our_zones = our_address()->pluck('zone_id')->unique(); // Find our uplinks that are hubs, NC, RC or ZCs // Find any system that also has heartbeat configured diff --git a/app/Models/Address.php b/app/Models/Address.php index 9b5f370..6fa59d7 100644 --- a/app/Models/Address.php +++ b/app/Models/Address.php @@ -846,6 +846,7 @@ class Address extends Model * Netmail alerts waiting to be sent to this system * * @return Collection + * @throws \Exception */ public function netmailAlertWaiting(): Collection { diff --git a/app/Models/Domain.php b/app/Models/Domain.php index f673e08..98296b4 100644 --- a/app/Models/Domain.php +++ b/app/Models/Domain.php @@ -146,16 +146,6 @@ class Domain extends Model */ public function managed(): bool { - static $so = NULL; - - if (is_null($so)) - $so = Setup::findOrFail(config('app.id')); - - return $so - ->system - ->addresses - ->where('zone.domain.active',TRUE) - ->pluck('zone.domain_id') - ->contains($this->id); + return our_address($this)->count() > 0; } } \ No newline at end of file diff --git a/app/Models/Echomail.php b/app/Models/Echomail.php index 4ae8b75..efbc265 100644 --- a/app/Models/Echomail.php +++ b/app/Models/Echomail.php @@ -214,7 +214,7 @@ final class Echomail extends Model implements Packet { Log::info(sprintf('%s:+ Bundling [%s]',self::LOGKEY,$this->id)); - $sysaddress = Setup::findOrFail(config('app.id'))->system->match($this->fftn->zone)->first(); + $sysaddress = our_address($this->fftn->zone->domain,$this->fftn); if (! $sysaddress) throw new \Exception(sprintf('%s:! We dont have an address in this network? (%s)',self::LOGKEY,$this->fftn->zone->domain->name)); diff --git a/app/Models/Netmail.php b/app/Models/Netmail.php index cbb1666..313b33a 100644 --- a/app/Models/Netmail.php +++ b/app/Models/Netmail.php @@ -206,12 +206,11 @@ final class Netmail extends Model implements Packet $o->tearline = $this->tearline; // VIA kludge - $sysaddress = Setup::findOrFail(config('app.id'))->system->match($this->fftn->zone)->first(); $via = $this->via ?: collect(); // Add our address to the VIA line $via->push( sprintf('%s @%s.UTC %s %d.%d/%s %s', - $sysaddress->ftn3d, + our_address($this->fftn->zone->domain,$this->fftn)->ftn3d, Carbon::now()->utc()->format('Ymd.His'), str_replace(' ','_',Setup::PRODUCT_NAME), Setup::PRODUCT_VERSION_MAJ, diff --git a/app/Models/System.php b/app/Models/System.php index 148ba31..abcf296 100644 --- a/app/Models/System.php +++ b/app/Models/System.php @@ -65,7 +65,12 @@ class System extends Model public function akas() { return $this->hasMany(Address::class) - ->active() + ->select('addresses.*') + ->join('zones',['zones.id'=>'addresses.zone_id']) + ->join('domains',['domains.id'=>'zones.domain_id']) + ->where('addresses.active',TRUE) + ->where('zones.active',TRUE) + ->where('domains.active',TRUE) ->FTNorder() ->orderBy('role','ASC'); } diff --git a/app/Notifications/Channels/EchomailChannel.php b/app/Notifications/Channels/EchomailChannel.php index bbf027c..4578118 100644 --- a/app/Notifications/Channels/EchomailChannel.php +++ b/app/Notifications/Channels/EchomailChannel.php @@ -39,8 +39,7 @@ class EchomailChannel if (! $echoarea = $notifiable->routeNotificationFor('echomail',$notification)) return; - $so = Setup::findOrFail(config('app.id'))->system; - $o = $notification->toEchomail($so,$notifiable); + $o = $notification->toEchomail($notifiable); Log::info(sprintf('%s:= Posted echomail [%s] to [%s]',self::LOGKEY,$o->msgid,$echoarea)); } diff --git a/app/Notifications/Channels/NetmailChannel.php b/app/Notifications/Channels/NetmailChannel.php index cfb5d7a..f8adf02 100644 --- a/app/Notifications/Channels/NetmailChannel.php +++ b/app/Notifications/Channels/NetmailChannel.php @@ -39,8 +39,7 @@ class NetmailChannel if (! $ao = $notifiable->routeNotificationFor('netmail',$notification)) return; - $so = Setup::findOrFail(config('app.id'))->system; - $o = $notification->toNetmail($so,$notifiable); + $o = $notification->toNetmail($notifiable); Log::info(sprintf('%s:= Sent netmail [%s] to [%s]',self::LOGKEY,$o->msgid,$ao->ftn)); } diff --git a/app/Notifications/Echomails.php b/app/Notifications/Echomails.php index d369640..e5ba88d 100644 --- a/app/Notifications/Echomails.php +++ b/app/Notifications/Echomails.php @@ -40,14 +40,13 @@ abstract class Echomails extends Notification //implements ShouldQueue /** * Get the mail representation of the notification. * - * @param System $so * @param mixed $notifiable * @return Echomail * @throws \Exception */ - abstract public function toEchomail(System $so,object $notifiable): Echomail; + abstract public function toEchomail(object $notifiable): Echomail; - protected function setupEchomail(Message $mo,System $so,object $notifiable): Echomail + protected function setupEchomail(Message $mo,object $notifiable): Echomail { $echoarea = $notifiable->routeNotificationFor(static::via); $eo = Echoarea::where('name',$echoarea)->singleOrFail(); @@ -61,7 +60,7 @@ abstract class Echomails extends Notification //implements ShouldQueue $o->datetime = Carbon::now(); $o->tzoffset = $o->datetime->utcOffset(); - $o->fftn_id = ($x=$so->match($mo->fboss_o->zone)->first())->id; + $o->fftn_id = ($x=our_address($mo->fboss_o->zone->domain,$mo->fboss_o))->id; $o->flags = (Message::FLAG_LOCAL); $o->tearline = sprintf('%s (%04X)',Setup::PRODUCT_NAME,Setup::PRODUCT_ID); diff --git a/app/Notifications/Echomails/Test.php b/app/Notifications/Echomails/Test.php index 19dd38d..031f931 100644 --- a/app/Notifications/Echomails/Test.php +++ b/app/Notifications/Echomails/Test.php @@ -34,14 +34,13 @@ class Test extends Echomails /** * Get the mail representation of the notification. * - * @param System $so * @param mixed $notifiable * @return Echomail * @throws \Exception */ - public function toEchomail(System $so,object $notifiable): Echomail + public function toEchomail(object $notifiable): Echomail { - $o = $this->setupEchomail($this->mo,$so,$notifiable); + $o = $this->setupEchomail($this->mo,$notifiable); $echoarea = $notifiable->routeNotificationFor(static::via); Log::info(sprintf('%s:+ Creating test echomail to [%s]',self::LOGKEY,$echoarea)); diff --git a/app/Notifications/Netmails.php b/app/Notifications/Netmails.php index a930319..5259575 100644 --- a/app/Notifications/Netmails.php +++ b/app/Notifications/Netmails.php @@ -40,14 +40,13 @@ abstract class Netmails extends Notification //implements ShouldQueue /** * Get the mail representation of the notification. * - * @param System $so * @param mixed $notifiable * @return Netmail * @throws \Exception */ - abstract public function toNetmail(System $so,object $notifiable): Netmail; + abstract public function toNetmail(object $notifiable): Netmail; - protected function setupNetmail(System $so,object $notifiable): Netmail + protected function setupNetmail(object $notifiable): Netmail { $ao = $notifiable->routeNotificationFor(static::via); @@ -58,7 +57,7 @@ abstract class Netmails extends Notification //implements ShouldQueue $o->datetime = Carbon::now(); $o->tzoffset = $o->datetime->utcOffset(); - $o->fftn_id = $so->match($ao->zone)->first()->id; + $o->fftn_id = our_address($ao->zone->domain,$ao); $o->tftn_id = $ao->id; $o->flags = (Message::FLAG_LOCAL|Message::FLAG_PRIVATE); $o->cost = 0; diff --git a/app/Notifications/Netmails/AddressLink.php b/app/Notifications/Netmails/AddressLink.php index d22c277..6ac7aab 100644 --- a/app/Notifications/Netmails/AddressLink.php +++ b/app/Notifications/Netmails/AddressLink.php @@ -31,14 +31,13 @@ class AddressLink extends Netmails /** * Get the mail representation of the notification. * - * @param System $so * @param mixed $notifiable * @return Netmail * @throws \Exception */ - public function toNetmail(System $so,object $notifiable): Netmail + public function toNetmail(object $notifiable): Netmail { - $o = $this->setupNetmail($so,$notifiable); + $o = $this->setupNetmail($notifiable); $ao = $notifiable->routeNotificationFor(static::via); Log::info(sprintf('%s:+ Sending a link code for address [%s]',self::LOGKEY,$ao->ftn)); diff --git a/app/Notifications/Netmails/Areafix.php b/app/Notifications/Netmails/Areafix.php index e205105..17ee5c4 100644 --- a/app/Notifications/Netmails/Areafix.php +++ b/app/Notifications/Netmails/Areafix.php @@ -32,14 +32,13 @@ class Areafix extends Netmails /** * Get the mail representation of the notification. * - * @param System $so * @param mixed $notifiable * @return Netmail * @throws \Exception */ - public function toNetmail(System $so,object $notifiable): Netmail + public function toNetmail(object $notifiable): Netmail { - $o = $this->setupNetmail($so,$notifiable); + $o = $this->setupNetmail($notifiable); $ao = $notifiable->routeNotificationFor(static::via); Log::info(sprintf('%s:+ Responding to areafix with netmail to [%s]',self::LOGKEY,$ao->ftn)); diff --git a/app/Notifications/Netmails/Areafix/NotConfiguredHere.php b/app/Notifications/Netmails/Areafix/NotConfiguredHere.php index 11eba5a..8650007 100644 --- a/app/Notifications/Netmails/Areafix/NotConfiguredHere.php +++ b/app/Notifications/Netmails/Areafix/NotConfiguredHere.php @@ -32,14 +32,13 @@ class NotConfiguredHere extends Netmails /** * Get the mail representation of the notification. * - * @param System $so * @param mixed $notifiable * @return Netmail * @throws \Exception */ - public function toNetmail(System $so,object $notifiable): Netmail + public function toNetmail(object $notifiable): Netmail { - $o = $this->setupNetmail($so,$notifiable); + $o = $this->setupNetmail($notifiable); $ao = $notifiable->routeNotificationFor(static::via); Log::info(sprintf('%s:+ Responding to areafix for a node [%s] not configured here',self::LOGKEY,$ao->ftn)); diff --git a/app/Notifications/Netmails/EchoareaNoWrite.php b/app/Notifications/Netmails/EchoareaNoWrite.php index 7522d87..1707554 100644 --- a/app/Notifications/Netmails/EchoareaNoWrite.php +++ b/app/Notifications/Netmails/EchoareaNoWrite.php @@ -33,14 +33,13 @@ class EchoareaNoWrite extends Netmails /** * Get the mail representation of the notification. * - * @param System $so * @param mixed $notifiable * @return Netmail * @throws \Exception */ - public function toNetmail(System $so,object $notifiable): Netmail + public function toNetmail(object $notifiable): Netmail { - $o = $this->setupNetmail($so,$notifiable); + $o = $this->setupNetmail($notifiable); $ao = $notifiable->routeNotificationFor(static::via); Log::info(sprintf('%s:+ Creating ECHOMAIL NO WRITE netmail to [%s]',self::LOGKEY,$ao->ftn)); diff --git a/app/Notifications/Netmails/EchoareaNotExist.php b/app/Notifications/Netmails/EchoareaNotExist.php index 26c1053..eff2e37 100644 --- a/app/Notifications/Netmails/EchoareaNotExist.php +++ b/app/Notifications/Netmails/EchoareaNotExist.php @@ -33,14 +33,13 @@ class EchoareaNotExist extends Netmails /** * Get the mail representation of the notification. * - * @param System $so * @param mixed $notifiable * @return Netmail * @throws \Exception */ - public function toNetmail(System $so,object $notifiable): Netmail + public function toNetmail(object $notifiable): Netmail { - $o = $this->setupNetmail($so,$notifiable); + $o = $this->setupNetmail($notifiable); $ao = $notifiable->routeNotificationFor(static::via); Log::info(sprintf('%s:+ Creating ECHOMAIL NOT EXIST netmail to [%s]',self::LOGKEY,$ao->ftn)); diff --git a/app/Notifications/Netmails/EchoareaNotSubscribed.php b/app/Notifications/Netmails/EchoareaNotSubscribed.php index 6328040..b8a2c07 100644 --- a/app/Notifications/Netmails/EchoareaNotSubscribed.php +++ b/app/Notifications/Netmails/EchoareaNotSubscribed.php @@ -33,14 +33,13 @@ class EchoareaNotSubscribed extends Netmails /** * Get the mail representation of the notification. * - * @param System $so * @param mixed $notifiable * @return Netmail * @throws \Exception */ - public function toNetmail(System $so,object $notifiable): Netmail + public function toNetmail(object $notifiable): Netmail { - $o = $this->setupNetmail($so,$notifiable); + $o = $this->setupNetmail($notifiable); $ao = $notifiable->routeNotificationFor(static::via); Log::info(sprintf('%s:+ Creating ECHOMAIL NOT SUBSCRIBED netmail to [%s]',self::LOGKEY,$ao->ftn)); diff --git a/app/Notifications/Netmails/EchomailBadAddress.php b/app/Notifications/Netmails/EchomailBadAddress.php index 5f8c42f..20c5ae3 100644 --- a/app/Notifications/Netmails/EchomailBadAddress.php +++ b/app/Notifications/Netmails/EchomailBadAddress.php @@ -33,14 +33,13 @@ class EchomailBadAddress extends Netmails /** * Get the mail representation of the notification. * - * @param System $so * @param mixed $notifiable * @return Netmail * @throws \Exception */ - public function toNetmail(System $so,object $notifiable): Netmail + public function toNetmail(object $notifiable): Netmail { - $o = $this->setupNetmail($so,$notifiable); + $o = $this->setupNetmail($notifiable); $ao = $notifiable->routeNotificationFor(static::via); Log::info(sprintf('%s:+ Creating ECHOMAIL BAD ADDRESS netmail to [%s]',self::LOGKEY,$ao->ftn)); diff --git a/app/Notifications/Netmails/NetmailForward.php b/app/Notifications/Netmails/NetmailForward.php index fd41466..95b067a 100644 --- a/app/Notifications/Netmails/NetmailForward.php +++ b/app/Notifications/Netmails/NetmailForward.php @@ -35,14 +35,13 @@ class NetmailForward extends Netmails /** * Get the mail representation of the notification. * - * @param System $so * @param mixed $notifiable * @return Netmail * @throws \Exception */ - public function toNetmail(System $so,object $notifiable): Netmail + public function toNetmail(object $notifiable): Netmail { - $o = $this->setupNetmail($so,$notifiable); + $o = $this->setupNetmail($notifiable); $ao = $notifiable->routeNotificationFor(static::via); Log::info(sprintf('%s:+ Advising [%s@%s] that netmail to [%s] will be forwarded to [%s].',self::LOGKEY,$this->mo->user_from,$ao->ftn,$this->mo->user_to,$this->ao->ftn)); diff --git a/app/Notifications/Netmails/PacketPasswordInvalid.php b/app/Notifications/Netmails/PacketPasswordInvalid.php index 9cf5dbc..3040c46 100644 --- a/app/Notifications/Netmails/PacketPasswordInvalid.php +++ b/app/Notifications/Netmails/PacketPasswordInvalid.php @@ -31,10 +31,13 @@ class PacketPasswordInvalid extends Netmails /** * Get the mail representation of the notification. + * + * @param mixed $notifiable + * @throws \Exception */ - public function toNetmail(System $so,object $notifiable): Netmail + public function toNetmail(object $notifiable): Netmail { - $o = $this->setupNetmail($so,$notifiable); + $o = $this->setupNetmail($notifiable); $ao = $notifiable->routeNotificationFor(static::via); Log::info(sprintf('%s:+ Creating netmail to [%s] - system using invalid packet password',self::LOGKEY,$ao->ftn)); diff --git a/app/Notifications/Netmails/Ping.php b/app/Notifications/Netmails/Ping.php index ec21d72..08708b8 100644 --- a/app/Notifications/Netmails/Ping.php +++ b/app/Notifications/Netmails/Ping.php @@ -34,14 +34,13 @@ class Ping extends Netmails /** * Get the mail representation of the notification. * - * @param System $so * @param mixed $notifiable * @return Netmail * @throws \Exception */ - public function toNetmail(System $so,object $notifiable): Netmail + public function toNetmail(object $notifiable): Netmail { - $o = $this->setupNetmail($so,$notifiable); + $o = $this->setupNetmail($notifiable); $ao = $notifiable->routeNotificationFor(static::via); Log::info(sprintf('%s:+ Creating PING netmail to [%s]',self::LOGKEY,$ao->ftn)); diff --git a/app/Notifications/Netmails/PollingFailed.php b/app/Notifications/Netmails/PollingFailed.php index 2aaf040..7208ebe 100644 --- a/app/Notifications/Netmails/PollingFailed.php +++ b/app/Notifications/Netmails/PollingFailed.php @@ -21,14 +21,13 @@ class PollingFailed extends Netmails /** * Get the mail representation of the notification. * - * @param System $so * @param mixed $notifiable * @return Netmail * @throws \Exception */ - public function toNetmail(System $so,object $notifiable): Netmail + public function toNetmail(object $notifiable): Netmail { - $o = $this->setupNetmail($so,$notifiable); + $o = $this->setupNetmail($notifiable); $ao = $notifiable->routeNotificationFor(static::via); Log::info(sprintf('%s:+ Creating auto hold netmail to [%s]',self::LOGKEY,$ao->ftn)); diff --git a/app/Notifications/Netmails/Reject.php b/app/Notifications/Netmails/Reject.php index eb3cd7e..87d98ed 100644 --- a/app/Notifications/Netmails/Reject.php +++ b/app/Notifications/Netmails/Reject.php @@ -33,14 +33,13 @@ class Reject extends Netmails /** * Get the mail representation of the notification. * - * @param System $so * @param mixed $notifiable * @return Netmail * @throws \Exception */ - public function toNetmail(System $so,object $notifiable): Netmail + public function toNetmail(object $notifiable): Netmail { - $o = $this->setupNetmail($so,$notifiable); + $o = $this->setupNetmail($notifiable); $ao = $notifiable->routeNotificationFor(static::via); Log::info(sprintf('%s:+ Creating reject netmail to [%s]',self::LOGKEY,$ao->ftn)); diff --git a/app/Notifications/Netmails/Test.php b/app/Notifications/Netmails/Test.php index 1a2a6a9..71b398f 100644 --- a/app/Notifications/Netmails/Test.php +++ b/app/Notifications/Netmails/Test.php @@ -17,14 +17,13 @@ class Test extends Netmails /** * Get the mail representation of the notification. * - * @param System $so * @param mixed $notifiable * @return Netmail * @throws \Exception */ - public function toNetmail(System $so,object $notifiable): Netmail + public function toNetmail(object $notifiable): Netmail { - $o = $this->setupNetmail($so,$notifiable); + $o = $this->setupNetmail($notifiable); $ao = $notifiable->routeNotificationFor(static::via); Log::info(sprintf('%s:+ Creating TEST netmail to [%s]',self::LOGKEY,$ao->ftn)); diff --git a/app/Traits/MsgID.php b/app/Traits/MsgID.php index 7ebc293..16f0609 100644 --- a/app/Traits/MsgID.php +++ b/app/Traits/MsgID.php @@ -15,11 +15,9 @@ trait MsgID public function save(array $options = []) { // Only create a MSGID for locally generated content - if ((! $this->exists) && ($this->flags & Message::FLAG_LOCAL)) { - $ftns = Setup::findOrFail(config('app.id'))->system->match($this->fftn->zone)->first(); - - if (is_null(Arr::get($this->attributes,'msgid'))) - $this->attributes['msgid'] = sprintf('%s %08x',$ftns->ftn4d,timew()); + if ((! $this->exists) && ($this->flags & Message::FLAG_LOCAL) && (is_null(Arr::get($this->attributes,'msgid')))) { + $ftn = our_address($this->fftn->zone->domain,$this->fftn); + $this->attributes['msgid'] = sprintf('%s %08x',$ftn->ftn4d,timew()); } return parent::save($options); diff --git a/app/helpers.php b/app/helpers.php index 41f9f82..5698c92 100644 --- a/app/helpers.php +++ b/app/helpers.php @@ -91,15 +91,13 @@ if (! function_exists('hexstr')) { */ function our_address(Domain $do=NULL,Address $ao=NULL): Collection|Address|NULL { - $our = Setup::findOrFail(config('app.id')) - ->system - ->akas; + $our = Setup::findOrFail(config('app.id'))->system->akas; if ($do) - $our = $our->filter(function($item) use ($do) { return $item->zone->domain_id === $do->id; }); + $our = $our->filter(function($item) use ($do) { return $item->zone->domain_id === $do->id; })->sortBy('role'); // 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()) + if ($ao && config('fido.strict') && ($x=$our->filter(function($item) use ($ao) { return $item->role <= $ao->role; })->sortBy('role'))->count()) $our = $x; return $ao ? $our->last() : $our; diff --git a/resources/views/setup.blade.php b/resources/views/setup.blade.php index 988ab43..55a119e 100644 --- a/resources/views/setup.blade.php +++ b/resources/views/setup.blade.php @@ -61,10 +61,10 @@ use App\Classes\Protocol\{Binkp,EMSI,DNS}; System Addresses - @foreach ($o->system->addresses->sortBy('zone.domain.name')->groupBy('zone_id') as $zones) + @foreach ($o->system->akas->sortBy('zone.domain.name')->groupBy('zone_id') as $addresses) - {{ $zones->first()->zone->domain->name }} - {!! $zones->pluck('ftn')->join('
') !!} + {{ $addresses->first()->zone->domain->name }} + {!! $addresses->pluck('ftn')->join('
') !!} @endforeach diff --git a/tests/Feature/RoutingTest.php b/tests/Feature/RoutingTest.php index f137098..fdb5af3 100644 --- a/tests/Feature/RoutingTest.php +++ b/tests/Feature/RoutingTest.php @@ -88,7 +88,7 @@ class RoutingTest extends TestCase // Make sure I'm configured correctly for the rest of the tests public function test_my_addresses() { - $ftns = Setup::findOrFail(config('app.id'))->system->addresses; + $ftns = our_address(); $this->assertEquals(1,$ftns->count()); }