Auto create FTN address for intransit netmail when the destination is not known.

This commit is contained in:
Deon George 2022-11-06 14:40:03 +11:00
parent 9a8ee1aa2b
commit 6284016400
4 changed files with 49 additions and 5 deletions

View File

@ -435,6 +435,48 @@ class Packet extends FTNBase implements \Iterator, \Countable
Log::info(sprintf('%s:- Message [%s] has errors',self::LOGKEY,$msg->msgid));
// If the from address doenst exist, we'll create a new entry
if ($msg->errors->messages()->has('to')) {
$e = NULL;
try {
Address::unguard();
$ao = Address::firstOrNew([
'zone_id' => $msg->tzone->id,
'region_id' => 0,
'host_id' => $msg->tn,
'node_id' => $msg->tf,
'point_id' => $msg->tp,
]);
Address::reguard();
} catch (\Exception $e) {
Log::error(sprintf('%s:! Error finding/creating address [%s] for message',self::LOGKEY,$msg->tboss));
}
// This shouldnt happen
if ($e || $ao->exists) {
Log::error(sprintf('%s:! Unexpected error attempting to create address [%s]',self::LOGKEY,$msg->tboss));
$this->errors->push($msg);
return;
}
$ao->active = TRUE;
$ao->role = Address::NODE_UNKNOWN;
System::unguard();
$so = System::firstOrCreate([
'name' => 'Discovered System',
'sysop' => 'Unknown',
'location' => '',
'active' => TRUE,
]);
System::reguard();
$so->addresses()->save($ao);
Log::alert(sprintf('%s: - To FTN is not defined, creating new entry for [%s] (%d)',self::LOGKEY,$msg->tboss,$ao->id));
}
if ($msg->errors->messages()->has('from')) {
$e = NULL;
@ -475,8 +517,9 @@ class Packet extends FTNBase implements \Iterator, \Countable
$so->addresses()->save($ao);
Log::alert(sprintf('%s: - From FTN is not defined, creating new entry for [%s] (%d)',self::LOGKEY,$msg->fboss,$ao->id));
}
} elseif($msg->errors->messages()->has('user_from') || $msg->errors->messages()->has('user_to')) {
if ($msg->errors->messages()->has('user_from') || $msg->errors->messages()->has('user_to')) {
Log::error(sprintf('%s:! Skipping message [%s] due to errors (%s)...',self::LOGKEY,$msg->msgid,join(',',$msg->errors->messages()->keys())));
$this->errors->push($msg);
return;

View File

@ -42,7 +42,7 @@ final class Test extends Process
$reply .= "\r";
$reply .= "\r";
$reply .= "------------------------------ BEING MESSAGE ------------------------------\r";
$reply .= "------------------------------ BEGIN MESSAGE ------------------------------\r";
$reply .= sprintf("TO: %s\r",$msg->user_to);
$reply .= sprintf("SUBJECT: %s\r",$msg->subject);
$reply .= $msg->message."\r";

View File

@ -122,7 +122,8 @@ class MessageProcess implements ShouldQueue
// If in transit, store for collection
} else {
Log::info(sprintf('Netmail [%s] in transit to (%s) [%s] from (%s) [%s].',
Log::info(sprintf('%s:Netmail [%s] in transit to (%s) [%s] from (%s) [%s].',
self::LOGKEY,
$this->msg->msgid,
$this->msg->user_to,$this->msg->tftn,
$this->msg->user_from,$this->msg->fftn,

View File

@ -128,7 +128,8 @@ class NodelistImport implements ShouldQueue
$node = 0;
switch ($fields[0]) {
case 'Zone': $zone = $fields[1];
case 'Zone':
$zone = $fields[1];
Zone::unguard();
$zo = Zone::firstOrNew([
'zone_id'=>$zone,
@ -364,7 +365,6 @@ class NodelistImport implements ShouldQueue
} catch (\Exception $e) {
Log::error(sprintf('%s:Error with line [%s] (%s)',self::LOGKEY,$line,$e->getMessage()),['fields'=>$fields]);
throw new \Exception($e->getMessage());
}
if (! ($c % 100)) {