From 9376c6de11b5aac9a7989d5213ef36e405b7976a Mon Sep 17 00:00:00 2001 From: Deon George Date: Wed, 20 Dec 2023 11:20:48 +1100 Subject: [PATCH] We should check for subscription before checking for permissions --- app/Jobs/MessageProcess.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/app/Jobs/MessageProcess.php b/app/Jobs/MessageProcess.php index fd519db..7391c6c 100644 --- a/app/Jobs/MessageProcess.php +++ b/app/Jobs/MessageProcess.php @@ -13,7 +13,7 @@ use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Notification; use App\Classes\FTN\Message; -use App\Models\{Address,Echoarea,Echomail,Netmail,Setup,User}; +use App\Models\{Address,Echoarea,Echomail,Netmail,User}; use App\Notifications\Netmails\{EchoareaNotExist,EchoareaNotSubscribed,EchoareaNoWrite,NetmailForward,Reject}; use App\Traits\ParseAddresses; @@ -334,6 +334,14 @@ class MessageProcess implements ShouldQueue )); } + // If the node is not subscribed + if ($this->pktsrc->echoareas->search(function($item) use ($ea) { return $item->id === $ea->id; }) === FALSE) { + Log::alert(sprintf('%s:! FTN [%s] is not subscribed to [%s] for [%s].',self::LOGKEY,$this->pktsrc->ftn,$ea->name,$this->msg->msgid)); + + if (! $this->msg->rescanned->count()) + Notification::route('netmail',$this->pktsrc)->notify(new EchoareaNotSubscribed($this->msg)); + } + // Can the system send messages to this area? if (! $ea->sec_write || ($this->pktsrc->security < $ea->sec_write)) { Log::alert(sprintf('%s:! FTN [%s] is not allowed to post [%s] to [%s].',self::LOGKEY,$this->pktsrc->ftn,$this->msg->msgid,$ea->name)); @@ -343,14 +351,6 @@ class MessageProcess implements ShouldQueue return; } - // If the node is not subscribed - if ($this->pktsrc->echoareas->search(function($item) use ($ea) { return $item->id === $ea->id; }) === FALSE) { - Log::alert(sprintf('%s:! FTN [%s] is not subscribed to [%s] for [%s].',self::LOGKEY,$this->pktsrc->ftn,$ea->name,$this->msg->msgid)); - - if (! $this->msg->rescanned->count()) - Notification::route('netmail',$this->pktsrc)->notify(new EchoareaNotSubscribed($this->msg)); - } - // We know about this area, store it $o = new Echomail; $o->init();