diff --git a/.env.testing b/.env.testing index 61d68aa..a69fdb1 100644 --- a/.env.testing +++ b/.env.testing @@ -5,7 +5,7 @@ APP_DEBUG=true #APP_URL=http://localhost LOG_CHANNEL=stderr -LOG_LEVEL=info +LOG_LEVEL=debug DB_CONNECTION=pgsql DB_HOST=postgres-test diff --git a/app/Classes/FTN/Message.php b/app/Classes/FTN/Message.php index 5641d57..fee9ae4 100644 --- a/app/Classes/FTN/Message.php +++ b/app/Classes/FTN/Message.php @@ -45,7 +45,6 @@ class Message extends FTNBase 'codepage' => 'CODEPAGE: ', 'dbid' => 'DBID: ', 'pid' => 'PID: ', - 'replyid' => 'REPLY: ', 'tid' => 'TID: ', ]; @@ -176,7 +175,6 @@ class Message extends FTNBase $this->zone = $zone; $this->header = []; - $this->kludge = collect(); $this->user_from = ''; $this->user_to = ''; @@ -234,6 +232,19 @@ class Message extends FTNBase return NULL; + case 'tdomain': + // We'll use the zone's domain if this method class was called with a zone + if ($this->zone && ($this->zone->domain->name == Arr::get($this->dst,'d'))) + return $this->zone->domain; + + // If we get the domain from the packet, we'll find it + if ($x=Arr::get($this->dst,'d')) { + return Domain::where('name',$x)->single(); + } + + // Otherwise we'll assume the same as the source domain + return $this->fdomain ?: NULL; + case 'fzone': // Use the zone if this class was called with it. if ($this->zone && ($this->fz == $this->zone->zone_id)) @@ -250,12 +261,28 @@ class Message extends FTNBase ->where('default',TRUE) ->single(); + case 'tzone': + // Use the zone if this class was called with it. + if ($this->zone && ($this->tz == $this->zone->zone_id)) + return $this->zone; + + // If we have a domain, we'll use the zone from the domain + if ($x=$this->tdomain) { + if (($x=$this->tdomain->zones->search(function($item) { return $item->zone_id == $this->tz; })) !== FALSE) + return $this->tdomain->zones->get($x); + } + + // No domain, so we'll use the default zone + return Zone::where('zone_id',$this->tz) + ->where('default',TRUE) + ->single(); + // To Addresses // Echomail doesnt have a zone, so we'll use the source zone case 'tz': return Arr::get($this->echoarea ? $this->src : $this->dst,'z'); case 'tn': return Arr::get($this->header,'dnet'); case 'tf': return Arr::get($this->header,'dnode'); - case 'tp': return Arr::get($this->dst,'p'); // @todo this wont work for netmails, since dst is not set for in transit messages + case 'tp': ;return Arr::get($this->dst,'p',0); // @todo this wont work for netmails, since dst is not set for in transit messages case 'fftn': case 'fftn_o': @@ -818,6 +845,9 @@ class Message extends FTNBase elseif ($t = $this->kludge('MSGID: ',$kl)) $this->msgid = $t; + elseif ($t = $this->kludge('REPLY: ',$kl)) + $this->replyid = $t; + elseif ($t = $this->kludge('GATE: ',$kl)) $this->gateid = $t; diff --git a/app/Classes/FTN/Packet.php b/app/Classes/FTN/Packet.php index ce68a78..c924b6d 100644 --- a/app/Classes/FTN/Packet.php +++ b/app/Classes/FTN/Packet.php @@ -450,12 +450,12 @@ class Packet extends FTNBase implements \Iterator, \Countable Address::reguard(); } catch (\Exception $e) { - Log::error(sprintf('%s:! Error finding/creating address [%s] for message',self::LOGKEY,$msg->tboss)); + Log::error(sprintf('%s:! Error finding/creating TO address [%s] for message',self::LOGKEY,$msg->tboss),['error'=>$e->getMessage()]); } // This shouldnt happen if ($e || $ao->exists) { - Log::error(sprintf('%s:! Unexpected error attempting to create address [%s]',self::LOGKEY,$msg->tboss)); + Log::error(sprintf('%s:! Unexpected error attempting to create TO address [%s]',self::LOGKEY,$msg->tboss)); $this->errors->push($msg); return; } @@ -492,12 +492,12 @@ class Packet extends FTNBase implements \Iterator, \Countable Address::reguard(); } catch (\Exception $e) { - Log::error(sprintf('%s:! Error finding/creating address [%s] for message',self::LOGKEY,$msg->fboss)); + Log::error(sprintf('%s:! Error finding/creating FROM address [%s] for message',self::LOGKEY,$msg->fboss),['error'=>$e->getMessage()]); } // This shouldnt happen if ($e || $ao->exists) { - Log::error(sprintf('%s:! Unexpected error attempting to create address [%s]',self::LOGKEY,$msg->fboss)); + Log::error(sprintf('%s:! Unexpected error attempting to create FROM address [%s]',self::LOGKEY,$msg->fboss)); $this->errors->push($msg); return; } diff --git a/app/Console/Commands/FilesList.php b/app/Console/Commands/FilesList.php new file mode 100644 index 0000000..7a1dce7 --- /dev/null +++ b/app/Console/Commands/FilesList.php @@ -0,0 +1,42 @@ +table([ + 'files.id' => 'ID', + 'file' => 'Filename', + 'area' => 'Filearea' + ],File::select(['files.id','file',DB::raw('fileareas.name AS filearea')]) + ->join('fileareas',['fileareas.id'=>'files.filearea_id']) + ->cursor()); + + return Command::SUCCESS; + } +} diff --git a/app/Console/Commands/PacketProcess.php b/app/Console/Commands/PacketProcess.php index 2e923da..3ce8317 100644 --- a/app/Console/Commands/PacketProcess.php +++ b/app/Console/Commands/PacketProcess.php @@ -7,7 +7,7 @@ use Symfony\Component\HttpFoundation\File\File; use App\Classes\FTN\Packet; use App\Jobs\MessageProcess as Job; -use App\Models\Zone; +use App\Models\Address; class PacketProcess extends Command { @@ -19,7 +19,7 @@ class PacketProcess extends Command protected $signature = 'packet:process' .' {pkt : Packet to process}' .' {--N|nobot : Dont process bots}' - .' {system? : Zone the packet is from}'; + .' {ftn? : System the packet is from}'; /** * The console command description. @@ -37,7 +37,7 @@ class PacketProcess extends Command public function handle() { $f = new File($this->argument('pkt')); - $s = $this->argument('system') ? Zone::where('name',$this->argument('system'))->singleOrFail() : NULL; + $s = $this->argument('ftn') ? Address::findFTN($this->argument('ftn'))->system : NULL; foreach (Packet::open($f,$s) as $msg) { // @todo Quick check that the packet should be processed by us. diff --git a/database/seeders/NodeHierarchy.php b/database/seeders/NodeHierarchy.php index 7b1e789..5a82885 100644 --- a/database/seeders/NodeHierarchy.php +++ b/database/seeders/NodeHierarchy.php @@ -36,9 +36,9 @@ class NodeHierarchy extends Seeder ]); foreach (['domain-a','domain-b'] as $domain) { - $domain = Domain::where('name',$domain)->singleOrFail(); - $this->hierarchy($domain,100); - $this->hierarchy($domain,101); + $do = Domain::where('name',$domain)->singleOrFail(); + $this->hierarchy($do,100); + $this->hierarchy($do,101); } } diff --git a/tests/Feature/PacketTest.php b/tests/Feature/PacketTest.php index b39d13a..1071c4b 100644 --- a/tests/Feature/PacketTest.php +++ b/tests/Feature/PacketTest.php @@ -106,9 +106,8 @@ class PacketTest extends TestCase $this->assertNotTrue($msg->isNetmail()); $this->assertCount(0,$msg->rogue_path); - $this->assertCount(2,$msg->rogue_seenby); + $this->assertCount(1,$msg->rogue_seenby); $this->assertNotFalse($msg->rogue_seenby->search('10:1/1')); - $this->assertNotFalse($msg->rogue_seenby->search('10:999/999')); $this->assertNotFalse($msg->seenaddress->search($src->id)); } @@ -181,7 +180,7 @@ class PacketTest extends TestCase $this->assertSame('61078e680cda04c8b5eba0f712582e70',md5($msg->message)); $this->assertSame('b9d65d4f7319ded282f3f1986276ae79',md5($msg->message_src)); $this->assertCount(1,$msg->pathaddress); - $this->assertCount(2,$msg->rogue_seenby); + $this->assertCount(1,$msg->rogue_seenby); $this->assertContains('1/1 999/1 999',$msg->seenby); $this->assertContains('999/1',$msg->path); $this->assertCount(1,$msg->seenby);