Limit where were respond to test messages

This commit is contained in:
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));