2021-07-15 14:54:23 +00:00
|
|
|
<?php
|
|
|
|
|
2021-09-12 12:14:04 +00:00
|
|
|
namespace App\Classes\FTN\Process\Netmail;
|
2021-07-15 14:54:23 +00:00
|
|
|
|
|
|
|
use Carbon\Carbon;
|
|
|
|
use Carbon\CarbonInterface;
|
2021-07-18 12:10:21 +00:00
|
|
|
use Illuminate\Support\Facades\Log;
|
2021-07-15 14:54:23 +00:00
|
|
|
|
|
|
|
use App\Classes\FTN\{Message,Process};
|
|
|
|
use App\Models\{Netmail,Setup};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Process messages to Ping
|
|
|
|
*
|
|
|
|
* @package App\Classes\FTN\Process
|
|
|
|
*/
|
|
|
|
final class Ping extends Process
|
|
|
|
{
|
2021-08-19 06:59:12 +00:00
|
|
|
private const LOGKEY = 'RP-';
|
|
|
|
|
2021-07-23 14:53:35 +00:00
|
|
|
private static array $logo = [
|
2021-07-15 14:54:23 +00:00
|
|
|
'ÚÄ¿þÚÄ¿ÚÄ¿',
|
|
|
|
'³ ³Â³ ³Àij',
|
|
|
|
'ÃÄÙÁÁ ÁÄÄÙ'
|
|
|
|
];
|
|
|
|
|
|
|
|
public static function handle(Message $msg): bool
|
|
|
|
{
|
|
|
|
if (strtolower($msg->user_to) !== 'ping')
|
|
|
|
return FALSE;
|
|
|
|
|
2021-08-19 06:59:12 +00:00
|
|
|
Log::info(sprintf('%s:- Processing PING message from (%s) [%s]',self::LOGKEY,$msg->user_from,$msg->fftn));
|
2021-08-08 13:53:56 +00:00
|
|
|
$ftns = Setup::findOrFail(config('app.id'))->system->match($msg->fftn_o->zone)->first();
|
2021-07-18 12:10:21 +00:00
|
|
|
|
2021-07-23 14:53:35 +00:00
|
|
|
$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",
|
2021-08-19 13:35:48 +00:00
|
|
|
Carbon::now()->utc()->toDateTimeString(),
|
2021-09-10 12:27:00 +00:00
|
|
|
$msg->date->utc()->toDateTimeString(),
|
2021-07-15 14:54:23 +00:00
|
|
|
$msg->date->diffForHumans(['parts'=>3,'syntax'=>CarbonInterface::DIFF_ABSOLUTE])
|
|
|
|
);
|
|
|
|
|
2021-07-17 05:48:07 +00:00
|
|
|
$reply .= "\r";
|
|
|
|
$reply .= "Your message travelled along this path on the way here:\r";
|
2021-07-15 14:54:23 +00:00
|
|
|
foreach ($msg->via as $path)
|
2021-07-17 05:48:07 +00:00
|
|
|
$reply .= sprintf(" * %s\r",$path);
|
2021-07-15 14:54:23 +00:00
|
|
|
|
2021-07-17 05:48:07 +00:00
|
|
|
$o = new Netmail;
|
2021-07-15 14:54:23 +00:00
|
|
|
$o->to = $msg->user_from;
|
|
|
|
$o->from = Setup::PRODUCT_NAME;
|
|
|
|
$o->subject = 'Ping Reply';
|
2021-07-30 14:35:52 +00:00
|
|
|
$o->datetime = Carbon::now();
|
|
|
|
$o->tzoffset = $o->datetime->utcOffset();
|
|
|
|
|
2022-01-01 05:59:35 +00:00
|
|
|
$o->replyid = $msg->msgid;
|
2021-08-08 13:53:56 +00:00
|
|
|
$o->fftn_id = $ftns->id;
|
2021-07-30 14:35:52 +00:00
|
|
|
$o->tftn_id = ($x=$msg->fftn_o) ? $x->id : NULL;
|
|
|
|
$o->flags = Message::FLAG_LOCAL;
|
|
|
|
$o->cost = 0;
|
2021-07-15 14:54:23 +00:00
|
|
|
|
2021-07-30 14:35:52 +00:00
|
|
|
$o->msg = static::format_msg($reply,self::$logo);
|
2021-07-18 12:10:21 +00:00
|
|
|
$o->tagline = 'My ping pong opponent was not happy with my serve. He kept returning it.';
|
2021-07-30 14:35:52 +00:00
|
|
|
$o->tearline = sprintf('%s (%04X)',Setup::PRODUCT_NAME,Setup::PRODUCT_ID);
|
2021-07-15 14:54:23 +00:00
|
|
|
$o->save();
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|