diff --git a/app/Classes/FTN/Message.php b/app/Classes/FTN/Message.php index bfa4267..459f5f9 100644 --- a/app/Classes/FTN/Message.php +++ b/app/Classes/FTN/Message.php @@ -451,7 +451,7 @@ class Message extends FTNBase $return .= $this->subject."\00"; if (! $this->isNetmail()) - $return .= sprintf("AREA:%s\r",$this->echoarea); + $return .= sprintf("AREA:%s\r",strtoupper($this->echoarea)); // If the message is local, then our kludges are not in the msg itself, we'll add them if ($this->isFlagSet(self::FLAG_LOCAL)) { @@ -573,7 +573,7 @@ class Message extends FTNBase // Check if this is an Echomail if (! strncmp(substr($msg,self::HEADER_LEN+$ptr),'AREA:',5)) { - $o->echoarea = substr($msg,self::HEADER_LEN+$ptr+5,strpos($msg,"\r",self::HEADER_LEN+$ptr+5)-(self::HEADER_LEN+$ptr+5)); + $o->echoarea = strtoupper(substr($msg,self::HEADER_LEN+$ptr+5,strpos($msg,"\r",self::HEADER_LEN+$ptr+5)-(self::HEADER_LEN+$ptr+5))); $ptr += strlen($o->echoarea)+5+1; } diff --git a/app/Classes/FTN/Process.php b/app/Classes/FTN/Process.php index d4a2cc7..43a71cf 100644 --- a/app/Classes/FTN/Process.php +++ b/app/Classes/FTN/Process.php @@ -2,11 +2,20 @@ namespace App\Classes\FTN; +use App\Models\Echoarea; + /** * Abstract class to hold the common functions for automatic responding to echomail/netmail messages */ abstract class Process { + public static function canProcess(string $echoarea): bool + { + $eao = Echoarea::where('name',$echoarea)->single(); + + return $eao && $eao->automsgs; + } + /** * Return TRUE if the process class handled the message. * diff --git a/app/Classes/FTN/Process/Echomail/Test.php b/app/Classes/FTN/Process/Echomail/Test.php index b7dae62..d47d28f 100644 --- a/app/Classes/FTN/Process/Echomail/Test.php +++ b/app/Classes/FTN/Process/Echomail/Test.php @@ -21,11 +21,12 @@ final class Test extends Process public static function handle(Message $msg): bool { - if ((strtolower($msg->user_to) !== 'all') || ! in_array(strtolower($msg->subject),self::testing)) + if (! self::canProcess($msg->echoarea) + || (strtolower($msg->user_to) !== 'all') + || (! in_array(strtolower($msg->subject),self::testing))) return FALSE; - // @todo Need to limit this to areas defined in config. - Log::info(sprintf('%s:- Processing TEST message from (%s) [%s]',self::LOGKEY,$msg->user_from,$msg->fftn)); + Log::info(sprintf('%s:- Processing TEST message from (%s) [%s] in [%s]',self::LOGKEY,$msg->user_from,$msg->fftn,$msg->echoarea)); Notification::route('echomail',$msg->echoarea)->notify(new TestNotification($msg)); diff --git a/app/Http/Controllers/EchoareaController.php b/app/Http/Controllers/EchoareaController.php index 6a7125b..abc71ad 100644 --- a/app/Http/Controllers/EchoareaController.php +++ b/app/Http/Controllers/EchoareaController.php @@ -22,11 +22,12 @@ class EchoareaController extends Controller 'description' => 'required', 'active' => 'required|boolean', 'show' => 'required|boolean', + 'automsgs' => 'required|boolean', 'sec_read' => 'required|integer|min:0|max:7', 'sec_write' => 'required|integer|min:0|max:7', ]); - foreach (['name','description','active','show','notes','domain_id'] as $key) + foreach (['name','description','active','show','notes','domain_id','automsgs'] as $key) $o->{$key} = $request->post($key); $o->setRead($request->post('sec_read')); diff --git a/database/migrations/2023_09_12_171249_echoarea_test_msgs.php b/database/migrations/2023_09_12_171249_echoarea_test_msgs.php new file mode 100644 index 0000000..d42d18f --- /dev/null +++ b/database/migrations/2023_09_12_171249_echoarea_test_msgs.php @@ -0,0 +1,28 @@ +boolean('automsgs')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('echoareas',function (Blueprint $table) { + $table->dropColumn('automsgs'); + }); + } +}; diff --git a/resources/views/echoarea/addedit.blade.php b/resources/views/echoarea/addedit.blade.php index 572562e..d1daa2e 100644 --- a/resources/views/echoarea/addedit.blade.php +++ b/resources/views/echoarea/addedit.blade.php @@ -35,7 +35,7 @@ -
+
@@ -54,10 +54,10 @@
- active ?? TRUE))checked @endif> + active ?? FALSE))checked @endif> - active ?? TRUE))checked @endif> + active ?? FALSE))checked @endif>
@@ -67,14 +67,27 @@
- show ?? TRUE))checked @endif> + show ?? FALSE))checked @endif> - show ?? TRUE))checked @endif> + show ?? FALSE))checked @endif>
+ +
+ +
+
+ automsgs ?? FALSE))checked @endif> + + + automsgs ?? FALSE))checked @endif> + +
+
+