Limit where were respond to test messages

This commit is contained in:
Deon George 2023-09-12 17:20:09 +10:00
parent 560bc2f8cb
commit 99866458a4
6 changed files with 63 additions and 11 deletions

View File

@ -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;
}

View File

@ -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.
*

View File

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

View File

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

View File

@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('echoareas',function (Blueprint $table) {
$table->boolean('automsgs')->nullable();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('echoareas',function (Blueprint $table) {
$table->dropColumn('automsgs');
});
}
};

View File

@ -35,7 +35,7 @@
</div>
</div>
<div class="col-4">
<div class="col-3">
<label for="name" class="form-label">Name</label>
<div class="input-group has-validation">
<span class="input-group-text"><i class="bi bi-tag-fill"></i></span>
@ -54,10 +54,10 @@
<label for="active" class="form-label">Active</label>
<div class="input-group">
<div class="btn-group" role="group">
<input type="radio" class="btn-check" name="active" id="active_yes" value="1" required @cannot('admin',$o)disabled @endcannot @if(old('active',$o->active ?? TRUE))checked @endif>
<input type="radio" class="btn-check" name="active" id="active_yes" value="1" required @cannot('admin',$o)disabled @endcannot @if(old('active',$o->active ?? FALSE))checked @endif>
<label class="btn btn-outline-success" for="active_yes">Yes</label>
<input type="radio" class="btn-check btn-danger" name="active" id="active_no" value="0" required @cannot('admin',$o)disabled @endcannot @if(! old('active',$o->active ?? TRUE))checked @endif>
<input type="radio" class="btn-check btn-danger" name="active" id="active_no" value="0" required @cannot('admin',$o)disabled @endcannot @if(! old('active',$o->active ?? FALSE))checked @endif>
<label class="btn btn-outline-danger" for="active_no">No</label>
</div>
</div>
@ -67,14 +67,27 @@
<label for="show" class="form-label">Show <i class="bi bi-info-circle" title="Show this area in the activity reports"></i></label>
<div class="input-group">
<div class="btn-group" role="group">
<input type="radio" class="btn-check" name="show" id="show_yes" value="1" required @cannot('admin',$o)disabled @endcannot @if(old('show',$o->show ?? TRUE))checked @endif>
<input type="radio" class="btn-check" name="show" id="show_yes" value="1" required @cannot('admin',$o)disabled @endcannot @if(old('show',$o->show ?? FALSE))checked @endif>
<label class="btn btn-outline-success" for="show_yes">Yes</label>
<input type="radio" class="btn-check btn-danger" name="show" id="show_no" value="0" required @cannot('admin',$o)disabled @endcannot @if(! old('show',$o->show ?? TRUE))checked @endif>
<input type="radio" class="btn-check btn-danger" name="show" id="show_no" value="0" required @cannot('admin',$o)disabled @endcannot @if(! old('show',$o->show ?? FALSE))checked @endif>
<label class="btn btn-outline-danger" for="show_no">No</label>
</div>
</div>
</div>
<div class="col-2">
<label for="automsgs" class="form-label">Auto Messages <i class="bi bi-info-circle" title="Automatically respond to some messages"></i></label>
<div class="input-group">
<div class="btn-group" role="group">
<input type="radio" class="btn-check" name="automsgs" id="automsgs_yes" value="1" required @cannot('admin',$o)disabled @endcannot @if(old('automsgs',$o->automsgs ?? FALSE))checked @endif>
<label class="btn btn-outline-success" for="automsgs_yes">Yes</label>
<input type="radio" class="btn-check btn-danger" name="automsgs" id="automsgs_no" value="0" required @cannot('admin',$o)disabled @endcannot @if(! old('automsgs',$o->automsgs ?? FALSE))checked @endif>
<label class="btn btn-outline-danger" for="automsgs_no">No</label>
</div>
</div>
</div>
</div>
<div class="row">