Move process functions to Netmail/Echomail folders, optimize Netmail creation when processing messages

This commit is contained in:
Deon George 2021-09-12 22:14:04 +10:00
parent f91778b515
commit 5e8b590f17
4 changed files with 28 additions and 33 deletions

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Classes\FTN\Process; namespace App\Classes\FTN\Process\Echomail;
use Carbon\Carbon; use Carbon\Carbon;
use Carbon\CarbonInterface; use Carbon\CarbonInterface;

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Classes\FTN\Process; namespace App\Classes\FTN\Process\Netmail;
use Carbon\Carbon; use Carbon\Carbon;
use Carbon\CarbonInterface; use Carbon\CarbonInterface;

View File

@ -61,20 +61,7 @@ class MessageProcess implements ShouldQueue
if (in_array(strtolower($this->msg->user_from),['filefix','areafix'])) { if (in_array(strtolower($this->msg->user_from),['filefix','areafix'])) {
Log::info(sprintf('Ignoring Netmail to the Hub from (%s) [%s] - its from a bot.',$this->msg->user_from,$this->msg->fftn)); Log::info(sprintf('Ignoring Netmail to the Hub from (%s) [%s] - its from a bot.',$this->msg->user_from,$this->msg->fftn));
$o = new Netmail; $o = $this->create_netmail($this->msg);
$o->to = $this->msg->user_to;
$o->from = $this->msg->user_from;
$o->subject = $this->msg->subject;
$o->datetime = $this->msg->date;
$o->tzoffset = $this->msg->date->utcOffset();
$o->flags = $this->msg->flags;
$o->cost = $this->msg->cost;
$o->msgid = $this->msg->msgid;
$o->fftn_id = ($x=$this->msg->fftn_o) ? $x->id : NULL;
$o->tftn_id = ($x=$this->msg->tftn_o) ? $x->id : NULL;
$o->msg = $this->msg->message_src;
$o->local = TRUE; $o->local = TRUE;
$o->save(); $o->save();
@ -144,21 +131,7 @@ class MessageProcess implements ShouldQueue
// @todo In transit loop checking // @todo In transit loop checking
// @todo In transit TRACE response // @todo In transit TRACE response
$o = new Netmail; $o = $this->create_netmail($this->msg);
$o->to = $this->msg->user_to;
$o->from = $this->msg->user_from;
$o->subject = $this->msg->subject;
$o->datetime = $this->msg->date;
$o->tzoffset = $this->msg->date->utcOffset();
$o->flags = $this->msg->flags;
$o->cost = $this->msg->cost;
$o->msgid = $this->msg->msgid;
$o->fftn_id = ($x=$this->msg->fftn_o) ? $x->id : NULL;
$o->tftn_id = ($x=$this->msg->tftn_o) ? $x->id : NULL;
$o->msg = $this->msg->message_src;
$o->save(); $o->save();
} }
@ -229,4 +202,26 @@ class MessageProcess implements ShouldQueue
} }
} }
} }
private function create_netmail(Message $msg): Netmail
{
$o = new Netmail;
$o->to = $msg->user_to;
$o->from = $msg->user_from;
$o->fftn_id = ($x=$msg->fftn_o) ? $x->id : NULL;
$o->tftn_id = ($x=$msg->tftn_o) ? $x->id : NULL;
$o->datetime = $msg->date;
$o->tzoffset = $msg->date->utcOffset();
$o->flags = $msg->flags;
$o->cost = $msg->cost;
$o->msgid = $msg->msgid;
$o->subject = $msg->subject;
$o->msg = $msg->message_src;
return $o;
}
} }

View File

@ -3,11 +3,11 @@
return [ return [
// Echmail // Echmail
'echomail' => [ 'echomail' => [
\App\Classes\FTN\Process\Test::class, \App\Classes\FTN\Process\Echomail\Test::class,
], ],
// Netmail // Netmail
'robots' => [ 'robots' => [
\App\Classes\FTN\Process\Ping::class, \App\Classes\FTN\Process\Netmail\Ping::class,
], ],
]; ];