No function changes. Cleanup console command cleanup
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
@@ -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;
|
||||
}
|
||||
}
|
136
app/Console/Commands/Debug/AddressMerge.php
Normal file
136
app/Console/Commands/Debug/AddressMerge.php
Normal file
@@ -0,0 +1,136 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Debug;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
use App\Models\{Address,System};
|
||||
|
||||
class AddressMerge extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'debug:address:merge'
|
||||
.' {src : Source Address}'
|
||||
.' {dst : Destination Address}'
|
||||
.' {--F|force : Force}'
|
||||
.' {--I|ignore : Ignore different BBSes}'
|
||||
.' {--d|dryrun : Dry Run}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Permanently remove a duplicate address';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
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));
|
||||
|
||||
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));
|
||||
|
||||
return self::FAILURE;
|
||||
}
|
||||
|
||||
if ($src->active) {
|
||||
$this->error(sprintf('Source [%s] is still active',$src->ftn));
|
||||
|
||||
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]);
|
||||
$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]);
|
||||
$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]);
|
||||
$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]);
|
||||
$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]);
|
||||
$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]);
|
||||
$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]);
|
||||
$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]);
|
||||
$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]);
|
||||
|
||||
} 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));
|
||||
|
||||
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]);
|
||||
} 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));
|
||||
|
||||
return self::FAILURE;
|
||||
}
|
||||
|
||||
$this->info(sprintf('Updated [%d] filearea subscription records',$x));
|
||||
|
||||
if ($this->option('dryrun')) {
|
||||
$this->warn(sprintf('NOT deleting [%s] - DRY RUN',$src->ftn));
|
||||
DB::rollBack();
|
||||
|
||||
} else {
|
||||
if ($src->forceDelete()) {
|
||||
$this->alert(sprintf('%s deleted.',$src->ftn));
|
||||
DB::commit();
|
||||
|
||||
} else {
|
||||
$this->warn(sprintf('Address [%s] didnt delete?',$src->ftn));
|
||||
DB::rollBack();
|
||||
}
|
||||
}
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
}
|
37
app/Console/Commands/Debug/EchomailDump.php
Normal file
37
app/Console/Commands/Debug/EchomailDump.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Debug;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
use App\Models\Echomail;
|
||||
|
||||
class EchomailDump extends Command
|
||||
{
|
||||
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'debug:echomail:dump {id}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Echomail Dump';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle(): int
|
||||
{
|
||||
dump(Echomail::findOrFail($this->argument('id')));
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
}
|
42
app/Console/Commands/Debug/NetmailTest.php
Normal file
42
app/Console/Commands/Debug/NetmailTest.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Debug;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
|
||||
use App\Models\Address;
|
||||
use App\Notifications\Netmails\Test as NetmailTestNotification;
|
||||
|
||||
class NetmailTest extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'debug:netmail:test'
|
||||
.' {ftn : FTN to send netmail to}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Send a netmail test message';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function handle():int
|
||||
{
|
||||
$ao = Address::findFTN($this->argument('ftn'));
|
||||
|
||||
Notification::route('netmail',$ao)->notify(new NetmailTestNotification());
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
}
|
@@ -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;
|
||||
}
|
||||
}
|
41
app/Console/Commands/Debug/SendTestEmail.php
Normal file
41
app/Console/Commands/Debug/SendTestEmail.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Debug;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
use App\Mail\TestEmail as MailTest;
|
||||
use App\Models\User;
|
||||
|
||||
class SendTestEmail extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'debug:email:test {id}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Send a test email';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle(): int
|
||||
{
|
||||
$uo = User::find($this->argument('id'));
|
||||
|
||||
Mail::to($uo->email)
|
||||
->send(new MailTest($uo));
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
}
|
@@ -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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user