Fix for when msgid address is from an unknown zone

This commit is contained in:
Deon George 2021-09-12 22:09:45 +10:00
parent 9462e66a1c
commit f91778b515

View File

@ -426,8 +426,9 @@ class Packet extends FTNBase implements \Iterator, \Countable
if ($msg->errors) { if ($msg->errors) {
// If the from address doenst exist, we'll create a new entry // If the from address doenst exist, we'll create a new entry
if ($msg->errors->messages()->has('from')) { if ($msg->errors->messages()->has('from')) {
Log::alert(sprintf('%s: - From FTN is not defined, creating new entry for [%s]',self::LOGKEY,$msg->fboss)); $e = NULL;
try {
Address::unguard(); Address::unguard();
$ao = Address::firstOrNew([ $ao = Address::firstOrNew([
'zone_id' => $msg->fzone->id, 'zone_id' => $msg->fzone->id,
@ -438,16 +439,20 @@ class Packet extends FTNBase implements \Iterator, \Countable
]); ]);
Address::reguard(); Address::reguard();
$ao->active = TRUE; } catch (\Exception $e) {
$ao->role = DomainController::NODE_UNKNOWN; Log::error(sprintf('%s:! Error finding/creating address [%s] for message',self::LOGKEY,$msg->fboss));
}
// This shouldnt happen // This shouldnt happen
if ($ao->exists) { if ($e || $ao->exists) {
Log::error(sprintf('%s: - Attempting to create address [%s], but it exists?',self::LOGKEY,$msg->fboss)); Log::error(sprintf('%s:! Attempting to create address [%s], but it exists?',self::LOGKEY,$msg->fboss));
$this->errors->push($msg); $this->errors->push($msg);
return; return;
} }
$ao->active = TRUE;
$ao->role = DomainController::NODE_UNKNOWN;
System::unguard(); System::unguard();
$so = System::firstOrCreate([ $so = System::firstOrCreate([
'name' => 'Discovered System', 'name' => 'Discovered System',
@ -459,6 +464,8 @@ class Packet extends FTNBase implements \Iterator, \Countable
$so->addresses()->save($ao); $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')) { } elseif($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()))); Log::error(sprintf('%s:! Skipping message [%s] due to errors (%s)...',self::LOGKEY,$msg->msgid,join(',',$msg->errors->messages()->keys())));
$this->errors->push($msg); $this->errors->push($msg);