Some message optimisation, added Echomail processing
This commit is contained in:
@@ -10,7 +10,7 @@ use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
use App\Classes\FTN\{Message,Process};
|
||||
use App\Models\{Netmail,Setup};
|
||||
use App\Models\{Echomail,Netmail,Setup};
|
||||
|
||||
class ProcessPacket implements ShouldQueue
|
||||
{
|
||||
@@ -86,13 +86,19 @@ class ProcessPacket implements ShouldQueue
|
||||
$o->to = $this->msg->user_from;
|
||||
$o->from = Setup::PRODUCT_NAME;
|
||||
$o->subject = 'Message Undeliverable - '.$this->msg->msgid;
|
||||
$o->datetime = $this->msg->date;
|
||||
$o->tzoffset = $this->msg->date->utcOffset();
|
||||
|
||||
$o->cost = 0;
|
||||
$o->flags = Message::FLAG_LOCAL;
|
||||
|
||||
$o->fftn_id = ($x=$this->msg->tftn_o) ? $x->id : NULL;
|
||||
$o->tftn_id = ($x=$this->msg->fftn_o) ? $x->id : NULL;
|
||||
$o->msg = Process::format_msg($reply,$reject);
|
||||
$o->reply = $this->msg->msgid;
|
||||
$o->msg = Process::format_msg($reply,$reject);
|
||||
|
||||
$o->tagline = 'Do you think it was fate which brought us together? Nah, bad luck :(';
|
||||
$o->tearline = sprintf('--- %s (%s)',Setup::PRODUCT_NAME,(new Setup)->version);
|
||||
$o->tearline = sprintf('%s (%04X)',Setup::PRODUCT_NAME,Setup::PRODUCT_ID);
|
||||
$o->save();
|
||||
}
|
||||
|
||||
@@ -108,32 +114,62 @@ class ProcessPacket implements ShouldQueue
|
||||
// @todo In transit loop checking
|
||||
// @todo In transit TRACE response
|
||||
|
||||
$o = new Netmail();
|
||||
$o = new Netmail;
|
||||
$o->to = $this->msg->user_to;
|
||||
$o->from = $this->msg->user_from;
|
||||
$o->subject = $this->msg->subject;
|
||||
$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;
|
||||
$o->tearline = $this->msg->tearline;
|
||||
$o->origin = $this->msg->origin;
|
||||
$o->kluge = json_encode($this->msg->kludge);
|
||||
$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();
|
||||
}
|
||||
|
||||
// Else we are echomail
|
||||
} else {
|
||||
dump('echomail');
|
||||
// Determine if we know about this echo area
|
||||
// Can the sender create it if it doesnt exist?
|
||||
// Create it, or
|
||||
Log::info(sprintf('Echomail [%s] in [%s] from (%s) [%s] to (%s).',
|
||||
$this->msg->msgid,
|
||||
$this->msg->echoarea,
|
||||
$this->msg->user_to,$this->msg->tftn,
|
||||
$this->msg->user_from,
|
||||
));
|
||||
|
||||
// Else record in bad area
|
||||
// @todo Determine if we know about this echo area
|
||||
// @todo Can the sender create it if it doesnt exist?
|
||||
// - Create it, or
|
||||
// - Else record in bad area
|
||||
|
||||
// We know about this area, store it
|
||||
$o = new Echomail;
|
||||
$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->fftn_id = ($x=$this->msg->fftn_o) ? $x->id : NULL;
|
||||
$o->echoarea = $this->msg->echoarea;
|
||||
$o->msgid = $this->msg->msgid;
|
||||
|
||||
$o->msg = $this->msg->message_src;
|
||||
// @todo Record Path
|
||||
// @todo Record SeenBy
|
||||
|
||||
$o->save();
|
||||
|
||||
// If the message is to a bot, we'll process it
|
||||
foreach (config('process.echomail') as $class) {
|
||||
if ($class::handle($this->msg)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user