2021-07-30 14:35:52 +00:00
|
|
|
<?php
|
|
|
|
|
2021-09-12 12:14:04 +00:00
|
|
|
namespace App\Classes\FTN\Process\Echomail;
|
2021-07-30 14:35:52 +00:00
|
|
|
|
|
|
|
use Carbon\Carbon;
|
|
|
|
use Carbon\CarbonInterface;
|
|
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
|
|
|
|
use App\Classes\FTN\{Message,Process};
|
2021-09-06 13:39:32 +00:00
|
|
|
use App\Models\{Echoarea,Echomail,Setup};
|
2021-07-30 14:35:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Process messages to Test
|
|
|
|
*
|
|
|
|
* @package App\Classes\FTN\Process
|
|
|
|
*/
|
|
|
|
final class Test extends Process
|
|
|
|
{
|
2021-09-06 13:39:32 +00:00
|
|
|
private const LOGKEY = 'RT-';
|
|
|
|
|
2021-07-30 14:35:52 +00:00
|
|
|
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;
|
|
|
|
|
2021-09-06 13:39:32 +00:00
|
|
|
Log::info(sprintf('%s:- Processing TEST message from (%s) [%s]',self::LOGKEY,$msg->user_from,$msg->fftn));
|
2021-09-26 13:34:27 +00:00
|
|
|
$ftns = Setup::findOrFail(config('app.id'))->system->match($msg->fboss_o->zone)->first();
|
2021-07-30 14:35:52 +00:00
|
|
|
|
|
|
|
$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",
|
2021-09-06 13:39:32 +00:00
|
|
|
Carbon::now()->utc()->toDateTimeString(),
|
2021-09-10 12:27:00 +00:00
|
|
|
$msg->date->utc()->toDateTimeString(),
|
2021-07-30 14:35:52 +00:00
|
|
|
$msg->date->diffForHumans(['parts'=>3,'syntax'=>CarbonInterface::DIFF_ABSOLUTE])
|
|
|
|
);
|
|
|
|
|
|
|
|
$reply .= "\r";
|
|
|
|
$reply .= "\r";
|
2022-11-06 03:40:03 +00:00
|
|
|
$reply .= "------------------------------ BEGIN MESSAGE ------------------------------\r";
|
2021-07-30 14:35:52 +00:00
|
|
|
$reply .= sprintf("TO: %s\r",$msg->user_to);
|
|
|
|
$reply .= sprintf("SUBJECT: %s\r",$msg->subject);
|
|
|
|
$reply .= $msg->message."\r";
|
|
|
|
$reply .= "------------------------------ CONTROL LINES ------------------------------\r";
|
2021-09-06 13:39:32 +00:00
|
|
|
$reply .= sprintf("DATE: %s\r",$msg->date->utc()->format('Y-m-d H:i:s'));
|
2021-07-30 14:35:52 +00:00
|
|
|
$reply .= sprintf("MSGID: %s\r",$msg->msgid);
|
|
|
|
|
|
|
|
foreach ($msg->kludge as $k=>$v)
|
2021-09-06 13:39:32 +00:00
|
|
|
$reply .= sprintf("@%s: %s\r",strtoupper($k),$v);
|
2021-07-30 14:35:52 +00:00
|
|
|
foreach ($msg->via as $via)
|
2021-09-06 13:39:32 +00:00
|
|
|
$reply .= sprintf("VIA: %s\r",$via);
|
2021-07-30 14:35:52 +00:00
|
|
|
|
|
|
|
$reply .= "------------------------------ END MESSAGE ------------------------------\r";
|
|
|
|
|
2021-09-06 13:39:32 +00:00
|
|
|
$eo = Echoarea::where('name',$msg->echoarea)->single();
|
|
|
|
|
2021-07-30 14:35:52 +00:00
|
|
|
$o = new Echomail;
|
2022-11-04 12:14:47 +00:00
|
|
|
$o->init();
|
2021-07-30 14:35:52 +00:00
|
|
|
$o->to = $msg->user_from;
|
|
|
|
$o->from = Setup::PRODUCT_NAME;
|
|
|
|
$o->subject = 'Test Reply';
|
|
|
|
$o->datetime = Carbon::now();
|
|
|
|
$o->tzoffset = $o->datetime->utcOffset();
|
2021-09-06 13:39:32 +00:00
|
|
|
$o->echoarea_id = $eo?->id;
|
2022-01-01 05:59:35 +00:00
|
|
|
$o->replyid = $msg->msgid;
|
2021-07-30 14:35:52 +00:00
|
|
|
$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);
|
2021-09-14 13:14:13 +00:00
|
|
|
$o->kludges = collect(['chrs'=>$msg->kludge->get('chrs') ?: 'CP437 2']);
|
2021-07-30 14:35:52 +00:00
|
|
|
$o->save();
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|