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";