We should check for subscription before checking for permissions

This commit is contained in:
Deon George 2023-12-20 11:20:48 +11:00
parent 713615d8d5
commit 9376c6de11
1 changed files with 9 additions and 9 deletions

View File

@ -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();