Echomail export

This commit is contained in:
Deon George
2021-09-06 23:39:32 +10:00
parent 8306f4c3a3
commit dbbfe46cb9
13 changed files with 163 additions and 62 deletions

View File

@@ -7,7 +7,7 @@ use Carbon\CarbonInterface;
use Illuminate\Support\Facades\Log;
use App\Classes\FTN\{Message,Process};
use App\Models\{Echomail,Setup};
use App\Models\{Echoarea,Echomail,Setup};
/**
* Process messages to Test
@@ -16,6 +16,8 @@ use App\Models\{Echomail,Setup};
*/
final class Test extends Process
{
private const LOGKEY = 'RT-';
private static array $logo = [
'Ú¿ÚÄ¿ÚĿڿ',
' ³ ³ÄÙÀÄ¿ ³ ',
@@ -29,12 +31,12 @@ final class Test extends Process
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));
Log::info(sprintf('%s:- Processing TEST message from (%s) [%s]',self::LOGKEY,$msg->user_from,$msg->fftn));
$ftns = Setup::findOrFail(config('app.id'))->system->match($msg->fftn_o->zone)->first();
$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->utc()->toDateTimeString(),
Carbon::now()->utc()->toDateTimeString(),
$msg->date->diffForHumans(['parts'=>3,'syntax'=>CarbonInterface::DIFF_ABSOLUTE])
);
@@ -45,23 +47,25 @@ final class Test extends Process
$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("DATE: %s\r",$msg->date->utc()->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);
$reply .= sprintf("@%s: %s\r",strtoupper($k),$v);
foreach ($msg->via as $via)
$reply .= sprintf("VIA: %s\n",$via);
$reply .= sprintf("VIA: %s\r",$via);
$reply .= "------------------------------ END MESSAGE ------------------------------\r";
$eo = Echoarea::where('name',$msg->echoarea)->single();
$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->echoarea_id = $eo?->id;
$o->reply = $msg->msgid;
$o->fftn_id = $ftns->id;