Some message optimisation, added Echomail processing
This commit is contained in:
@@ -28,6 +28,7 @@ final class Ping extends Process
|
||||
return FALSE;
|
||||
|
||||
Log::info(sprintf('Processing PING message from (%s) [%s]',$msg->user_from,$msg->fftn));
|
||||
$ftns = Setup::findOrFail(config('app.id'))->system->match($msg->fftn_o->zone);
|
||||
|
||||
$reply = sprintf("Your ping was received here on %s and it looks like you sent it on %s. If that is correct, then it took %s to get here.\r",
|
||||
$msg->date->toDateTimeString(),
|
||||
@@ -45,13 +46,18 @@ final class Ping extends Process
|
||||
$o->to = $msg->user_from;
|
||||
$o->from = Setup::PRODUCT_NAME;
|
||||
$o->subject = 'Ping Reply';
|
||||
$o->fftn_id = ($x=$msg->tftn_o) ? $x->id : NULL;
|
||||
$o->tftn_id = ($x=$msg->fftn_o) ? $x->id : NULL;
|
||||
$o->msg = static::format_msg($reply,self::$logo);
|
||||
$o->reply = $msg->msgid;
|
||||
$o->datetime = Carbon::now();
|
||||
$o->tzoffset = $o->datetime->utcOffset();
|
||||
|
||||
$o->reply = $msg->msgid;
|
||||
$o->fftn_id = $ftns->id;
|
||||
$o->tftn_id = ($x=$msg->fftn_o) ? $x->id : NULL;
|
||||
$o->flags = Message::FLAG_LOCAL;
|
||||
$o->cost = 0;
|
||||
|
||||
$o->msg = static::format_msg($reply,self::$logo);
|
||||
$o->tagline = 'My ping pong opponent was not happy with my serve. He kept returning it.';
|
||||
$o->tearline = sprintf('--- %s (%s)',Setup::PRODUCT_NAME,(new Setup)->version);
|
||||
$o->tearline = sprintf('%s (%04X)',Setup::PRODUCT_NAME,Setup::PRODUCT_ID);
|
||||
$o->save();
|
||||
|
||||
return TRUE;
|
||||
|
77
app/Classes/FTN/Process/Test.php
Normal file
77
app/Classes/FTN/Process/Test.php
Normal file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\FTN\Process;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Carbon\CarbonInterface;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
use App\Classes\FTN\{Message,Process};
|
||||
use App\Models\{Echomail,Setup};
|
||||
|
||||
/**
|
||||
* Process messages to Test
|
||||
*
|
||||
* @package App\Classes\FTN\Process
|
||||
*/
|
||||
final class Test extends Process
|
||||
{
|
||||
private static array $logo = [
|
||||
'Ú¿ÚÄ¿ÚĿڿ',
|
||||
' ³ ³ÄÙÀÄ¿ ³ ',
|
||||
' Á ÀÄÙÀÄÙ Á '
|
||||
];
|
||||
|
||||
private const testing = ['test','testing'];
|
||||
|
||||
public static function handle(Message $msg): bool
|
||||
{
|
||||
if ((strtolower($msg->user_to) !== 'all') || ! in_array(strtolower($msg->subject),self::testing))
|
||||
return FALSE;
|
||||
|
||||
Log::info(sprintf('Processing TEST message from (%s) [%s]',$msg->user_from,$msg->fftn));
|
||||
$ftns = Setup::findOrFail(config('app.id'))->system->match($msg->fftn_o->zone);
|
||||
|
||||
$reply = sprintf("Your test was received here on %s and it looks like you sent it on %s. If that is correct, then it took %s to get here.\r",
|
||||
$msg->date->toDateTimeString(),
|
||||
Carbon::now()->toDateTimeString(),
|
||||
$msg->date->diffForHumans(['parts'=>3,'syntax'=>CarbonInterface::DIFF_ABSOLUTE])
|
||||
);
|
||||
|
||||
$reply .= "\r";
|
||||
$reply .= "\r";
|
||||
$reply .= "------------------------------ BEING MESSAGE ------------------------------\r";
|
||||
$reply .= sprintf("TO: %s\r",$msg->user_to);
|
||||
$reply .= sprintf("SUBJECT: %s\r",$msg->subject);
|
||||
$reply .= $msg->message."\r";
|
||||
$reply .= "------------------------------ CONTROL LINES ------------------------------\r";
|
||||
$reply .= sprintf("DATE: %s\r",$msg->date->format('Y-m-d H:i:s'));
|
||||
$reply .= sprintf("MSGID: %s\r",$msg->msgid);
|
||||
|
||||
foreach ($msg->kludge as $k=>$v)
|
||||
$reply .= sprintf("@%s: %s\n",strtoupper($k),$v);
|
||||
foreach ($msg->via as $via)
|
||||
$reply .= sprintf("VIA: %s\n",$via);
|
||||
|
||||
$reply .= "------------------------------ END MESSAGE ------------------------------\r";
|
||||
|
||||
$o = new Echomail;
|
||||
$o->to = $msg->user_from;
|
||||
$o->from = Setup::PRODUCT_NAME;
|
||||
$o->subject = 'Test Reply';
|
||||
$o->datetime = Carbon::now();
|
||||
$o->tzoffset = $o->datetime->utcOffset();
|
||||
$o->echoarea = $msg->echoarea;
|
||||
$o->reply = $msg->msgid;
|
||||
$o->fftn_id = $ftns->id;
|
||||
|
||||
$o->flags = Message::FLAG_LOCAL;
|
||||
$o->msg = static::format_msg($reply,self::$logo);
|
||||
$o->tagline = 'I ate a clock yesterday, it was very time-consuming.';
|
||||
$o->tearline = sprintf('%s (%04X)',Setup::PRODUCT_NAME,Setup::PRODUCT_ID);
|
||||
$o->origin = sprintf('%s (%s)',Setup::PRODUCT_NAME,$ftns->ftn4d);
|
||||
$o->save();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user