No function changes. Cleanup console command cleanup
All checks were successful
Create Docker Image / Build Docker Image (x86_64) (push) Successful in 40s
Create Docker Image / Build Docker Image (arm64) (push) Successful in 1m43s
Create Docker Image / Final Docker Image Manifest (push) Successful in 10s

This commit is contained in:
Deon George 2024-05-27 15:08:39 +10:00
parent 3a594acc03
commit e15331ec35
28 changed files with 124 additions and 82 deletions

View File

@ -26,10 +26,12 @@ class ANSIDecode extends Command
/**
* Execute the console command.
*
* @return mixed
* @return int
*/
public function handle()
public function handle(): int
{
echo ANSI::ansi($this->argument('file'));
return self::SUCCESS;
}
}

View File

@ -26,9 +26,9 @@ class ANSIEncode extends Command
/**
* Execute the console command.
*
* @return mixed
* @return int
*/
public function handle()
public function handle(): int
{
foreach (ANSI::binary($this->argument('file')) as $line) {
foreach (str_split(bin2hex($line),2) as $y)
@ -36,5 +36,7 @@ class ANSIEncode extends Command
echo "\r";
}
return self::SUCCESS;
}
}

View File

@ -28,12 +28,10 @@ class AddressIdle extends Command
/**
* Execute the console command.
*/
public function handle()
public function handle(): int
{
$do = Domain::where('name',$this->argument('domain'))->singleOrFail();
Job::dispatchSync($do,$this->option('ftn') ? Address::findFTN($this->option('ftn')) : NULL);
return self::SUCCESS;
return Job::dispatchSync($do,$this->option('ftn') ? Address::findFTN($this->option('ftn')) : NULL);
}
}

View File

@ -26,10 +26,10 @@ class Rescan extends Command
/**
* Execute the console command.
*
* @return mixed
* @return int
* @throws \Exception
*/
public function handle()
public function handle(): int
{
if (($this->argument('days')) && (! is_numeric($this->argument('days'))))
throw new \Exception('Days must be numeric: '.$this->argument('days'));

View File

@ -13,7 +13,7 @@ class AddressCheck extends Command
protected $description = 'Check the addresses we use for a node';
public function handle()
public function handle(): int
{
$o = Address::findFTN($this->argument('ftn'));
@ -29,6 +29,6 @@ class AddressCheck extends Command
$this->info(sprintf('Our Address: %s',our_address($o)?->ftn));
$this->info(sprintf('- Domain Addresses: %s',our_address($o->zone->domain)->pluck('ftn4d')->join(',')));
return Command::SUCCESS;
return self::SUCCESS;
}
}

View File

@ -24,7 +24,7 @@ class AddressCheckRole extends Command
/**
* Execute the console command.
*/
public function handle()
public function handle(): int
{
foreach (Address::withTrashed()->with(['zone.domain'])->cursor() as $o) {
// Trim the role bit from role, since we now work out a role automatically.
@ -44,5 +44,7 @@ class AddressCheckRole extends Command
}
}
}
return self::SUCCESS;
}
}

View File

@ -1,6 +1,6 @@
<?php
namespace App\Console\Commands;
namespace App\Console\Commands\Debug;
use Illuminate\Console\Command;
use Illuminate\Database\QueryException;
@ -15,7 +15,7 @@ class AddressMerge extends Command
*
* @var string
*/
protected $signature = 'address:merge'
protected $signature = 'debug:address:merge'
.' {src : Source Address}'
.' {dst : Destination Address}'
.' {--F|force : Force}'
@ -34,79 +34,84 @@ class AddressMerge extends Command
*
* @return int
*/
public function handle()
public function handle(): int
{
$src = Address::withTrashed()->findOrfail($this->argument('src'));
$dst = Address::withTrashed()->findOrfail($this->argument('dst'));
if ((! $this->option('ignore')) && ($src->system_id !== $dst->system_id) && ($src->system->name !== System::default)) {
$this->error(sprintf('FTN addresses are from different systems (%s/%s)',$src->system->name,$dst->system->name));
exit(1);
return self::FAILURE;
}
if ((! $this->option('force')) && ($src->ftn !== $dst->ftn)) {
$this->error(sprintf('FTN addresses are not the same (%s:%s)',$src->ftn,$dst->ftn));
exit(1);
return self::FAILURE;
}
if ($src->active) {
$this->error(sprintf('Source [%s] is still active',$src->ftn));
exit(1);
return self::FAILURE;
}
DB::beginTransaction();
// Find all echomail seenbys
$x = DB::update('update echomail_seenby set address_id=? where address_id=?',[$dst->id,$src->id]);
$x = DB::update('UPDATE echomail_seenby SET address_id=? WHERE address_id=?',[$dst->id,$src->id]);
$this->info(sprintf('Updated [%d] echomail seenby records',$x));
// Find all echomail paths
$x = DB::update('update echomail_path set address_id=? where address_id=?',[$dst->id,$src->id]);
$x = DB::update('UPDATE echomail_path SET address_id=? WHERE address_id=?',[$dst->id,$src->id]);
$this->info(sprintf('Updated [%d] echomail path records',$x));
// Find all echomails
$x = DB::update('update echomails set fftn_id=? where fftn_id=?',[$dst->id,$src->id]);
$x = DB::update('UPDATE echomails SET fftn_id=? WHERE fftn_id=?',[$dst->id,$src->id]);
$this->info(sprintf('Updated [%d] echomail source records',$x));
// Find all netmails
$x = DB::update('update netmails set fftn_id=? where fftn_id=?',[$dst->id,$src->id]);
$x = DB::update('UPDATE netmails SET fftn_id=? WHERE fftn_id=?',[$dst->id,$src->id]);
$this->info(sprintf('Updated [%d] netmail source records',$x));
// Find all netmails
$x = DB::update('update netmails set tftn_id=? where tftn_id=?',[$dst->id,$src->id]);
$x = DB::update('UPDATE netmails SET tftn_id=? WHERE tftn_id=?',[$dst->id,$src->id]);
$this->info(sprintf('Updated [%d] netmail destination records',$x));
// Find all nodelist
$x = DB::update('update address_nodelist set address_id=? where address_id=?',[$dst->id,$src->id]);
$x = DB::update('UPDATE address_nodelist SET address_id=? WHERE address_id=?',[$dst->id,$src->id]);
$this->info(sprintf('Updated [%d] nodelist records',$x));
// Find all file seenbys
$x = DB::update('update file_seenby set address_id=? where address_id=?',[$dst->id,$src->id]);
$x = DB::update('UPDATE file_seenby SET address_id=? WHERE address_id=?',[$dst->id,$src->id]);
$this->info(sprintf('Updated [%d] file seenby records',$x));
// Find all files
$x = DB::update('update files set fftn_id=? where fftn_id=?',[$dst->id,$src->id]);
$x = DB::update('UPDATE files SET fftn_id=? WHERE fftn_id=?',[$dst->id,$src->id]);
$this->info(sprintf('Updated [%d] file source records',$x));
// Resubscribe echoareas
try {
$x = DB::update('update address_echoarea set address_id=? where address_id=?',[$dst->id,$src->id]);
$x = DB::update('UPDATE address_echoarea SET address_id=? WHERE address_id=?',[$dst->id,$src->id]);
} catch (QueryException $e) {
DB::rollback();
$this->error(sprintf('You may need to remove %s:%s (%d) from echoareas',$src->ftn,$src->system->name,$src->id));
exit(1);
return self::FAILURE;
}
$this->info(sprintf('Updated [%d] echomail subscription records',$x));
// Resubscribe fileareas
try {
$x = DB::update('update address_filearea set address_id=? where address_id=?',[$dst->id,$src->id]);
$x = DB::update('UPDATE address_filearea SET address_id=? WHERE address_id=?',[$dst->id,$src->id]);
} catch (QueryException $e) {
DB::rollback();
$this->error(sprintf('You may need to remove %s:%s (%d) from fileareas',$src->ftn,$src->system->name,$src->id));
exit(1);
return self::FAILURE;
}
$this->info(sprintf('Updated [%d] filearea subscription records',$x));
@ -126,6 +131,6 @@ class AddressMerge extends Command
}
}
return Command::SUCCESS;
return self::SUCCESS;
}
}

View File

@ -1,6 +1,6 @@
<?php
namespace App\Console\Commands;
namespace App\Console\Commands\Debug;
use Illuminate\Console\Command;
@ -14,7 +14,7 @@ class EchomailDump extends Command
*
* @var string
*/
protected $signature = 'echomail:dump {id}';
protected $signature = 'debug:echomail:dump {id}';
/**
* The console command description.
@ -26,10 +26,12 @@ class EchomailDump extends Command
/**
* Execute the console command.
*
* @return mixed
* @return int
*/
public function handle()
public function handle(): int
{
dump(Echomail::findOrFail($this->argument('id')));
return self::SUCCESS;
}
}

View File

@ -1,6 +1,6 @@
<?php
namespace App\Console\Commands;
namespace App\Console\Commands\Debug;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Notification;
@ -15,7 +15,7 @@ class NetmailTest extends Command
*
* @var string
*/
protected $signature = 'netmail:test'
protected $signature = 'debug:netmail:test'
.' {ftn : FTN to send netmail to}';
/**
@ -28,13 +28,15 @@ class NetmailTest extends Command
/**
* Execute the console command.
*
* @return mixed
* @return int
* @throws \Exception
*/
public function handle()
public function handle():int
{
$ao = Address::findFTN($this->argument('ftn'));
Notification::route('netmail',$ao)->notify(new NetmailTestNotification());
return self::SUCCESS;
}
}

View File

@ -29,10 +29,10 @@ class PacketAddress extends Command
/**
* Execute the console command.
*
* @return mixed
* @return int
* @throws \Exception
*/
public function handle()
public function handle(): int
{
$ao = Address::findFTN($this->argument('ftn'));
@ -57,6 +57,6 @@ class PacketAddress extends Command
->generate()
);
return Command::SUCCESS;
return self::SUCCESS;
}
}

View File

@ -1,6 +1,6 @@
<?php
namespace App\Console\Commands;
namespace App\Console\Commands\Debug;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Mail;
@ -15,7 +15,7 @@ class SendTestEmail extends Command
*
* @var string
*/
protected $signature = 'email:test {id}';
protected $signature = 'debug:email:test {id}';
/**
* The console command description.
@ -27,13 +27,15 @@ class SendTestEmail extends Command
/**
* Execute the console command.
*
* @return mixed
* @return int
*/
public function handle()
public function handle(): int
{
$uo = User::find($this->argument('id'));
Mail::to($uo->email)
->send(new MailTest($uo));
return self::SUCCESS;
}
}

View File

@ -14,7 +14,7 @@ class ZoneCheck extends Command
protected $description = 'Check that the addresses in a zone are configured correctly';
public function handle()
public function handle(): int
{
$do = Domain::where('name',$this->argument('domain'))->singleOrFail();
@ -42,6 +42,6 @@ class ZoneCheck extends Command
}));
}
return Command::SUCCESS;
return self::SUCCESS;
}
}

View File

@ -30,9 +30,9 @@ class EchoareaImport extends Command
/**
* Execute the console command.
*
* @return mixed
* @return int
*/
public function handle()
public function handle(): int
{
$do = Domain::where('name',strtolower($this->argument('domain')))->singleOrFail();
return Job::dispatchSync($this->argument('file'),$do,$this->option('prefix'),$this->option('unlink'));

View File

@ -30,9 +30,9 @@ class FileareaImport extends Command
/**
* Execute the console command.
*
* @return mixed
* @return int
*/
public function handle()
public function handle(): int
{
$do = Domain::where('name',strtolower($this->argument('domain')))->singleOrFail();
return Job::dispatchSync($this->argument('file'),$do,$this->option('prefix'),$this->option('unlink'));

View File

@ -26,10 +26,10 @@ class Rescan extends Command
/**
* Execute the console command.
*
* @return mixed
* @return int
* @throws \Exception
*/
public function handle()
public function handle(): int
{
$ao = Address::findFtn($this->argument('ftn'));

View File

@ -27,7 +27,7 @@ class FilesList extends Command
*
* @return int
*/
public function handle()
public function handle(): int
{
$this->table([
'files.id' => 'ID',
@ -37,6 +37,6 @@ class FilesList extends Command
->join('fileareas',['fileareas.id'=>'files.filearea_id'])
->cursor());
return Command::SUCCESS;
return self::SUCCESS;
}
}

View File

@ -25,7 +25,7 @@ class JobList extends Command
/**
* Execute the console command.
*/
public function handle()
public function handle(): int
{
$lastq = NULL;
@ -45,5 +45,7 @@ class JobList extends Command
$o->attempts ? sprintf(' (Created:%s)',$o->created_at) : ''
));
}
return self::SUCCESS;
}
}

View File

@ -28,7 +28,7 @@ class MailList extends Command
* @return int
* @throws \Exception
*/
public function handle()
public function handle(): int
{
$ao = Address::findFTN($this->argument('ftn'),TRUE);

View File

@ -32,9 +32,9 @@ class NodelistImport extends Command
/**
* Execute the console command.
*
* @return mixed
* @return int
*/
public function handle()
public function handle():int
{
try {
return Job::dispatchSync(
@ -50,6 +50,8 @@ class NodelistImport extends Command
} catch (\Exception $e) {
$this->error($e->getMessage());
return self::FAILURE;
}
}
}

View File

@ -30,10 +30,10 @@ class PacketInfo extends Command
/**
* Execute the console command.
*
* @return mixed
* @return int
* @throws \App\Exceptions\InvalidPacketException
*/
public function handle()
public function handle():int
{
$fs = Storage::disk(config('fido.local_disk'));
$rel_name = sprintf('%s/%s',config('fido.dir'),$this->argument('file'));
@ -109,5 +109,7 @@ class PacketInfo extends Command
$this->line("\n");
}
return self::SUCCESS;
}
}

View File

@ -58,10 +58,10 @@ class PacketProcess extends Command
/**
* Execute the console command.
*
* @return int|void
* @return int
* @throws \Exception
*/
public function handle()
public function handle(): int
{
$rel_name = sprintf('%s/%s',config('fido.dir'),$this->argument('file'));
@ -74,7 +74,8 @@ class PacketProcess extends Command
} else {
$this->error('Unable to determine sender FTN address');
exit(1);
return self::FAILURE;
}
Job::dispatchSync($rel_name,$ao->zone->domain,$this->option('dontqueue'));

View File

@ -29,7 +29,7 @@ class PacketSystem extends Command
* @return int
* @throws \Exception
*/
public function handle()
public function handle(): int
{
$ao = Address::findFTN($this->argument('ftn'));

View File

@ -30,10 +30,10 @@ class ServerStart extends Command
/**
* Execute the console command.
*
* @return void
* @return int
* @throws SocketException
*/
public function handle()
public function handle(): int
{
Log::info(sprintf('%s:+ Server Starting (%d)',self::LOGKEY,getmypid()));
$o = Setup::findOrFail(config('app.id'));
@ -71,7 +71,7 @@ class ServerStart extends Command
if (! $start->count()) {
Log::alert(sprintf('%s:! No servers configured to start',self::LOGKEY));
return;
return self::FAILURE;
}
pcntl_signal(SIGCHLD,SIG_IGN);
@ -105,7 +105,7 @@ class ServerStart extends Command
Log::info(sprintf('%s:= Finished: [%s]',self::LOGKEY,$item));
// Child finished we need to get out of this loop.
exit;
return self::SUCCESS;
}
Log::debug(sprintf('%s:- Forked for [%s] (%d)',self::LOGKEY,$item,$pid));
@ -125,5 +125,7 @@ class ServerStart extends Command
// Done
Log::debug(sprintf('%s:= Finished.',self::LOGKEY));
return self::SUCCESS;
}
}

View File

@ -27,9 +27,9 @@ class SystemHeartbeat extends Command
/**
* Execute the console command.
*/
public function handle()
public function handle(): int
{
Log::info('CSH:- Triggering heartbeat to systems');
Job::dispatchSync($this->option('force'));
return Job::dispatchSync($this->option('force'));
}
}

View File

@ -29,11 +29,9 @@ class TicProcess extends Command
*
* @return int
*/
public function handle()
public function handle(): int
{
// Dispatch job.
Job::dispatchSync($this->argument('file'),$this->argument('domain'));
return Command::SUCCESS;
return Job::dispatchSync($this->argument('file'),$this->argument('domain'));
}
}

View File

@ -19,14 +19,16 @@ class UserCodeSend extends Command
/**
* Execute the console command.
*
* @return mixed
* @return int
* @throws \Exception
*/
public function handle()
public function handle(): int
{
$ao = Address::findFTN($this->argument('ftn'));
$uo = User::where('email',$this->argument('email'))->singleOrFail();
Notification::route('netmail',$ao->uplink())->notify(new AddressLink($uo));
return self::SUCCESS;
}
}

View File

@ -27,12 +27,14 @@ class UserMakeAdmin extends Command
*
* @return int
*/
public function handle()
public function handle(): int
{
$o = User::where('email',$this->argument('email'))->firstOrfail();
$o->admin = ! $o->admin;
$o->save();
$this->info(sprintf('User [%s] %s an admin',$o->email,$o->admin ? 'IS' : 'is NOT'));
return self::SUCCESS;
}
}

View File

@ -15,28 +15,44 @@ return [
*/
'hide' => [
'about',
'auth:*',
'cache:*',
'channel:*',
'clear-compiled',
'completion',
'config:*',
'db:*',
'docs',
'debugbar:*',
'event:*',
'env:*',
'ide-helper:*',
'install:*',
'inspire',
'key:generate',
'lang:*',
'list',
'make:*',
'migrate:*',
'model:*',
'model:prune',
'notifications:table',
'optimize:*',
'package:discover',
'queue:listen',
'queue:prune-batches',
'queue:prune-failed',
'queue:retry',
'queue:retry-batch',
'queue:work',
'route:*',
'sanctum:*',
'serve',
'schedule:*',
'schema:dump',
'session:table',
'storage:link',
'storage:*',
'stub:publish',
'test',
'theme:*',