Create TO ftn (for netmails), identify REPLYID, add file:list
This commit is contained in:
parent
6284016400
commit
eab36c1603
@ -5,7 +5,7 @@ APP_DEBUG=true
|
|||||||
#APP_URL=http://localhost
|
#APP_URL=http://localhost
|
||||||
|
|
||||||
LOG_CHANNEL=stderr
|
LOG_CHANNEL=stderr
|
||||||
LOG_LEVEL=info
|
LOG_LEVEL=debug
|
||||||
|
|
||||||
DB_CONNECTION=pgsql
|
DB_CONNECTION=pgsql
|
||||||
DB_HOST=postgres-test
|
DB_HOST=postgres-test
|
||||||
|
@ -45,7 +45,6 @@ class Message extends FTNBase
|
|||||||
'codepage' => 'CODEPAGE: ',
|
'codepage' => 'CODEPAGE: ',
|
||||||
'dbid' => 'DBID: ',
|
'dbid' => 'DBID: ',
|
||||||
'pid' => 'PID: ',
|
'pid' => 'PID: ',
|
||||||
'replyid' => 'REPLY: ',
|
|
||||||
'tid' => 'TID: ',
|
'tid' => 'TID: ',
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -176,7 +175,6 @@ class Message extends FTNBase
|
|||||||
$this->zone = $zone;
|
$this->zone = $zone;
|
||||||
|
|
||||||
$this->header = [];
|
$this->header = [];
|
||||||
$this->kludge = collect();
|
|
||||||
|
|
||||||
$this->user_from = '';
|
$this->user_from = '';
|
||||||
$this->user_to = '';
|
$this->user_to = '';
|
||||||
@ -234,6 +232,19 @@ class Message extends FTNBase
|
|||||||
|
|
||||||
return NULL;
|
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':
|
case 'fzone':
|
||||||
// Use the zone if this class was called with it.
|
// Use the zone if this class was called with it.
|
||||||
if ($this->zone && ($this->fz == $this->zone->zone_id))
|
if ($this->zone && ($this->fz == $this->zone->zone_id))
|
||||||
@ -250,12 +261,28 @@ class Message extends FTNBase
|
|||||||
->where('default',TRUE)
|
->where('default',TRUE)
|
||||||
->single();
|
->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
|
// To Addresses
|
||||||
// Echomail doesnt have a zone, so we'll use the source zone
|
// 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 'tz': return Arr::get($this->echoarea ? $this->src : $this->dst,'z');
|
||||||
case 'tn': return Arr::get($this->header,'dnet');
|
case 'tn': return Arr::get($this->header,'dnet');
|
||||||
case 'tf': return Arr::get($this->header,'dnode');
|
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':
|
||||||
case 'fftn_o':
|
case 'fftn_o':
|
||||||
@ -818,6 +845,9 @@ class Message extends FTNBase
|
|||||||
elseif ($t = $this->kludge('MSGID: ',$kl))
|
elseif ($t = $this->kludge('MSGID: ',$kl))
|
||||||
$this->msgid = $t;
|
$this->msgid = $t;
|
||||||
|
|
||||||
|
elseif ($t = $this->kludge('REPLY: ',$kl))
|
||||||
|
$this->replyid = $t;
|
||||||
|
|
||||||
elseif ($t = $this->kludge('GATE: ',$kl))
|
elseif ($t = $this->kludge('GATE: ',$kl))
|
||||||
$this->gateid = $t;
|
$this->gateid = $t;
|
||||||
|
|
||||||
|
@ -450,12 +450,12 @@ class Packet extends FTNBase implements \Iterator, \Countable
|
|||||||
Address::reguard();
|
Address::reguard();
|
||||||
|
|
||||||
} catch (\Exception $e) {
|
} 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
|
// This shouldnt happen
|
||||||
if ($e || $ao->exists) {
|
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);
|
$this->errors->push($msg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -492,12 +492,12 @@ class Packet extends FTNBase implements \Iterator, \Countable
|
|||||||
Address::reguard();
|
Address::reguard();
|
||||||
|
|
||||||
} catch (\Exception $e) {
|
} 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
|
// This shouldnt happen
|
||||||
if ($e || $ao->exists) {
|
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);
|
$this->errors->push($msg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
42
app/Console/Commands/FilesList.php
Normal file
42
app/Console/Commands/FilesList.php
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use App\Models\File;
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
class FilesList extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'files:list';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'List files';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
$this->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;
|
||||||
|
}
|
||||||
|
}
|
@ -7,7 +7,7 @@ use Symfony\Component\HttpFoundation\File\File;
|
|||||||
|
|
||||||
use App\Classes\FTN\Packet;
|
use App\Classes\FTN\Packet;
|
||||||
use App\Jobs\MessageProcess as Job;
|
use App\Jobs\MessageProcess as Job;
|
||||||
use App\Models\Zone;
|
use App\Models\Address;
|
||||||
|
|
||||||
class PacketProcess extends Command
|
class PacketProcess extends Command
|
||||||
{
|
{
|
||||||
@ -19,7 +19,7 @@ class PacketProcess extends Command
|
|||||||
protected $signature = 'packet:process'
|
protected $signature = 'packet:process'
|
||||||
.' {pkt : Packet to process}'
|
.' {pkt : Packet to process}'
|
||||||
.' {--N|nobot : Dont process bots}'
|
.' {--N|nobot : Dont process bots}'
|
||||||
.' {system? : Zone the packet is from}';
|
.' {ftn? : System the packet is from}';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The console command description.
|
* The console command description.
|
||||||
@ -37,7 +37,7 @@ class PacketProcess extends Command
|
|||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
$f = new File($this->argument('pkt'));
|
$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) {
|
foreach (Packet::open($f,$s) as $msg) {
|
||||||
// @todo Quick check that the packet should be processed by us.
|
// @todo Quick check that the packet should be processed by us.
|
||||||
|
@ -36,9 +36,9 @@ class NodeHierarchy extends Seeder
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
foreach (['domain-a','domain-b'] as $domain) {
|
foreach (['domain-a','domain-b'] as $domain) {
|
||||||
$domain = Domain::where('name',$domain)->singleOrFail();
|
$do = Domain::where('name',$domain)->singleOrFail();
|
||||||
$this->hierarchy($domain,100);
|
$this->hierarchy($do,100);
|
||||||
$this->hierarchy($domain,101);
|
$this->hierarchy($do,101);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,9 +106,8 @@ class PacketTest extends TestCase
|
|||||||
$this->assertNotTrue($msg->isNetmail());
|
$this->assertNotTrue($msg->isNetmail());
|
||||||
$this->assertCount(0,$msg->rogue_path);
|
$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:1/1'));
|
||||||
$this->assertNotFalse($msg->rogue_seenby->search('10:999/999'));
|
|
||||||
|
|
||||||
$this->assertNotFalse($msg->seenaddress->search($src->id));
|
$this->assertNotFalse($msg->seenaddress->search($src->id));
|
||||||
}
|
}
|
||||||
@ -181,7 +180,7 @@ class PacketTest extends TestCase
|
|||||||
$this->assertSame('61078e680cda04c8b5eba0f712582e70',md5($msg->message));
|
$this->assertSame('61078e680cda04c8b5eba0f712582e70',md5($msg->message));
|
||||||
$this->assertSame('b9d65d4f7319ded282f3f1986276ae79',md5($msg->message_src));
|
$this->assertSame('b9d65d4f7319ded282f3f1986276ae79',md5($msg->message_src));
|
||||||
$this->assertCount(1,$msg->pathaddress);
|
$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('1/1 999/1 999',$msg->seenby);
|
||||||
$this->assertContains('999/1',$msg->path);
|
$this->assertContains('999/1',$msg->path);
|
||||||
$this->assertCount(1,$msg->seenby);
|
$this->assertCount(1,$msg->seenby);
|
||||||
|
Loading…
Reference in New Issue
Block a user