Command refactoring - no functional changes
This commit is contained in:
parent
0fe65d6187
commit
2495e4675c
@ -21,7 +21,7 @@ class ANSIDecode extends Command
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Encode ANS file to custom binary';
|
||||
protected $description = 'Decode ANS file from custom binary';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
|
@ -10,14 +10,14 @@ use App\Classes\Sock\SocketException;
|
||||
use App\Classes\Sock\SocketServer;
|
||||
use App\Models\Setup;
|
||||
|
||||
class BinkpReceive extends Command
|
||||
class CommBinkpReceive extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'binkp:receive';
|
||||
protected $signature = 'comm:binkp:receive';
|
||||
|
||||
/**
|
||||
* The console command description.
|
@ -9,21 +9,21 @@ use Illuminate\Support\Facades\Log;
|
||||
use App\Models\Address;
|
||||
use App\Jobs\AddressPoll as Job;
|
||||
|
||||
class BinkpSend extends Command
|
||||
class CommBinkpSend extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'binkp:send {ftn : FTN to Send to}';
|
||||
protected $signature = 'comm:binkp:send {ftn : FTN to Send to}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Binkp send';
|
||||
protected $description = 'BINKP send';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
@ -10,14 +10,14 @@ use App\Classes\Sock\SocketException;
|
||||
use App\Classes\Sock\SocketServer;
|
||||
use App\Models\Setup;
|
||||
|
||||
class EMSIReceive extends Command
|
||||
class CommEMSIReceive extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'emsi:receive';
|
||||
protected $signature = 'comm:emsi:receive';
|
||||
|
||||
/**
|
||||
* The console command description.
|
@ -9,14 +9,14 @@ use Illuminate\Support\Facades\Log;
|
||||
use App\Models\Address;
|
||||
use App\Jobs\AddressPoll as Job;
|
||||
|
||||
class EMSISend extends Command
|
||||
class CommEMSISend extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'emsi:send {ftn : FTN to Send to}';
|
||||
protected $signature = 'comm:emsi:send {ftn : FTN to Send to}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
@ -9,14 +9,14 @@ use App\Classes\Sock\SocketException;
|
||||
use App\Classes\Sock\SocketServer;
|
||||
use App\Classes\Protocol\Zmodem as ZmodemClass;
|
||||
|
||||
class ZmodemReceive extends Command
|
||||
class CommZmodemReceive extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'zmodem:receive';
|
||||
protected $signature = 'comm:zmodem:receive';
|
||||
|
||||
/**
|
||||
* The console command description.
|
@ -6,17 +6,17 @@ use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
use App\Classes\Protocol;
|
||||
use App\Classes\Sock\SocketClient;
|
||||
use App\Classes\Protocol\Zmodem as ZmodemClass;
|
||||
use App\Classes\Sock\SocketClient;
|
||||
|
||||
class ZmodemSend extends Command
|
||||
class CommZmodemSend extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'zmodem:send {ip}';
|
||||
protected $signature = 'comm:zmodem:send {ip}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
@ -1,161 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\Echoarea;
|
||||
use App\Models\Echomail;
|
||||
use App\Models\Netmail;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
|
||||
class ConvertMongo extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'convert:mongo {start=0}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Convert Mongo to Cockroach';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
/*
|
||||
// Netmails
|
||||
foreach (DB::connection('mongodb')->collection('netmails')->cursor() as $o) {
|
||||
$o['mid'] = (string)$o['_id'];
|
||||
|
||||
foreach([
|
||||
'reply'=>'replyid',
|
||||
'packet'=>'sent_pkt',
|
||||
] as $key => $newkey) {
|
||||
if (array_key_exists($key,$o)) {
|
||||
$o[$newkey] = $o[$key];
|
||||
unset($o[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
unset($o['_id'],$o['sent'],$o['reply']);
|
||||
|
||||
foreach (['created_at','updated_at','sent_at','datetime','deleted_at'] as $key) {
|
||||
if (Arr::get($o,$key))
|
||||
$o[$key] = Carbon::create($o[$key]->toDatetime());
|
||||
}
|
||||
|
||||
if (! Arr::get($o,'datetime'))
|
||||
$o['datetime'] = $o['created_at'];
|
||||
|
||||
$oo = Netmail::withTrashed()->where('mid',$o['mid'])->firstOrNew();
|
||||
$oo->forceFill($o);
|
||||
|
||||
try {
|
||||
$oo->save(['timestamps' => false]);
|
||||
} catch (\Exception $e) {
|
||||
$this->warn(sprintf('Netmail didnt move over: %s (%s)',$o['mid'],$e->getMessage()));
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
/**/
|
||||
// Echomail
|
||||
$c = 0;
|
||||
foreach (DB::connection('mongodb')->collection('echomails')->cursor() as $o) {
|
||||
if (++$c < $this->argument('start'))
|
||||
continue;
|
||||
|
||||
if (! ($c%100))
|
||||
Log::debug(sprintf('Processed : %d Echomails',$c));
|
||||
|
||||
$o['mid'] = (string)$o['_id'];
|
||||
|
||||
foreach([
|
||||
'reply'=>'replyid',
|
||||
'rogue_seen'=>'rogue_seenby',
|
||||
] as $key => $newkey) {
|
||||
if (array_key_exists($key,$o)) {
|
||||
$o[$newkey] = $o[$key];
|
||||
unset($o[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
$path = (array_key_exists('path',$o) && $o['path']) ? $o['path'] : NULL;
|
||||
$seenby = (array_key_exists('seenby',$o) && $o['seenby']) ? $o['seenby'] : NULL;
|
||||
$packet = (array_key_exists('packet',$o) && $o['packet']) ? $o['packet'] : NULL;
|
||||
|
||||
unset($o['_id'],$o['reply'],$o['path'],$o['seenby'],$o['toexport'],$o['sent_at'],$o['packet'],$o['sent']);
|
||||
|
||||
foreach (['created_at','updated_at','datetime','deleted_at'] as $key) {
|
||||
if (Arr::get($o,$key))
|
||||
$o[$key] = Carbon::create($o[$key]->toDatetime());
|
||||
}
|
||||
|
||||
if (! Arr::get($o,'datetime'))
|
||||
$o['datetime'] = $o['created_at'];
|
||||
|
||||
if (Arr::get($o,'echoarea') && ! Arr::get($o,'echoarea_id')) {
|
||||
$ea = Echoarea::where('name',$o['echoarea'])->single();
|
||||
$o['echoarea_id'] = $ea->id;
|
||||
unset($o['echoarea']);
|
||||
}
|
||||
|
||||
if (! $o['echoarea_id']) {
|
||||
Log::error(sprintf('Echomail didnt move over: %s [%d] - has no echoarea_id',$o['mid'],$c));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Arr::get($o,'msg_src') && ! Arr::get($o,'msg_crc')) {
|
||||
$o['msg_crc'] = 'x'.md5($o['msg_src']);
|
||||
}
|
||||
|
||||
$oo = Echomail::withTrashed()->where('mid',$o['mid'])->firstOrNew();
|
||||
$oo->forceFill($o);
|
||||
$oo->set_path = $path ? array_filter($path) : [];
|
||||
$oo->set_seenby = $seenby ? array_filter($seenby): [];
|
||||
$oo->set_packet = $packet;
|
||||
$oo->no_export = TRUE;
|
||||
|
||||
try {
|
||||
$oo->save(['timestamps'=>FALSE]);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
Log::error(sprintf('Echomail didnt move over: %s [%d] (%s@%d|%s)',$o['mid'],$c,$e->getFile(),$e->getLine(),$e->getMessage()));
|
||||
dd(['e'=>$e,'o'=>$o,'oo'=>$oo]);
|
||||
}
|
||||
|
||||
DB::connection('mongodb')->collection('echomails')->delete($o['mid']);
|
||||
}
|
||||
/**/
|
||||
|
||||
// Update old MID seenby with proper ID
|
||||
foreach (DB::connection('cockroach')->table('echomail_seenby')->whereNotNull('mid')->whereNull('echomail_id')->cursor() as $o)
|
||||
{
|
||||
$eo = Echomail::where('mid',$o->mid)->get();
|
||||
|
||||
if ($eo->count() && $eo->count() == 1) {
|
||||
DB::update('UPDATE echomail_seenby set echomail_id = ?, mid=NULL where echomail_id IS NULL AND mid = ? ',[
|
||||
$eo->first()->id,
|
||||
$o->mid,
|
||||
]);
|
||||
|
||||
} elseif ($eo->count() > 1) {
|
||||
Log::error(sprintf('Echomail [%s] has more than 1 record [%d] - skipped',$o->mid,$eo->count()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -2,9 +2,9 @@
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\Domain;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
use App\Models\Domain;
|
||||
use App\Jobs\EchoareaImport as Job;
|
||||
|
||||
class EchoareaImport extends Command
|
||||
|
@ -6,9 +6,9 @@ use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
|
||||
use App\Models\Address;
|
||||
use App\Notifications\NetmailTest;
|
||||
use App\Notifications\NetmailTest as NetmailTestNotification;
|
||||
|
||||
class SendTestNetmail extends Command
|
||||
class NetmailTest extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
@ -35,6 +35,6 @@ class SendTestNetmail extends Command
|
||||
{
|
||||
$ao = Address::findFTN($this->argument('ftn'));
|
||||
|
||||
Notification::route('netmail',$ao)->notify(new NetmailTest($ao));
|
||||
Notification::route('netmail',$ao)->notify(new NetmailTestNotification($ao));
|
||||
}
|
||||
}
|
@ -10,7 +10,7 @@ use App\Classes\Sock\SocketException;
|
||||
use App\Classes\Sock\SocketServer;
|
||||
use App\Models\Setup;
|
||||
|
||||
class StartServer extends Command
|
||||
class ServerStart extends Command
|
||||
{
|
||||
private const LOGKEY = 'CSS';
|
||||
|
@ -6,14 +6,14 @@ use Illuminate\Console\Command;
|
||||
|
||||
use App\Models\User;
|
||||
|
||||
class MakeAdmin extends Command
|
||||
class UserMakeAdmin extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'make:admin {email : User Email}';
|
||||
protected $signature = 'user:make:admin {email : User Email}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
Loading…
Reference in New Issue
Block a user