Rename address:merge to address:purge, included merging file/echo subscriptions, updated web subscription cannot add echos to deleted ftns
This commit is contained in:
parent
ccf187d710
commit
102a972fcb
@ -2,21 +2,24 @@
|
|||||||
|
|
||||||
namespace App\Console\Commands;
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
use App\Models\Address;
|
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
|
use Illuminate\Database\QueryException;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
class AddressPurge extends Command
|
use App\Models\Address;
|
||||||
|
|
||||||
|
class AddressMerge extends Command
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The name and signature of the console command.
|
* The name and signature of the console command.
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $signature = 'address:purge'
|
protected $signature = 'address:merge'
|
||||||
.' {src : Source Address}'
|
.' {src : Source Address}'
|
||||||
.' {dst : Destination Address}'
|
.' {dst : Destination Address}'
|
||||||
.' {--f|force : Force}'
|
.' {--F|force : Force}'
|
||||||
|
.' {--I|ignore : Ignore different BBSes}'
|
||||||
.' {--d|dryrun : Dry Run}';
|
.' {--d|dryrun : Dry Run}';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -36,12 +39,12 @@ class AddressPurge extends Command
|
|||||||
$src = Address::withTrashed()->findOrfail($this->argument('src'));
|
$src = Address::withTrashed()->findOrfail($this->argument('src'));
|
||||||
$dst = Address::withTrashed()->findOrfail($this->argument('dst'));
|
$dst = Address::withTrashed()->findOrfail($this->argument('dst'));
|
||||||
|
|
||||||
if (($src->system_id !== $dst->system_id) && ($src->system->name !== 'Discovered System')) {
|
if ((! $this->option('ignore')) && ($src->system_id !== $dst->system_id) && ($src->system->name !== 'Discovered System')) {
|
||||||
$this->error(sprintf('FTN addresses are from different systems (%s/%s)',$src->system->name,$dst->system->name));
|
$this->error(sprintf('FTN addresses are from different systems (%s/%s)',$src->system->name,$dst->system->name));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $this->option('force') && ($src->ftn !== $dst->ftn)) {
|
if ((! $this->option('force')) && ($src->ftn !== $dst->ftn)) {
|
||||||
$this->error(sprintf('FTN addresses are not the same (%s:%s)',$src->ftn,$dst->ftn));
|
$this->error(sprintf('FTN addresses are not the same (%s:%s)',$src->ftn,$dst->ftn));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@ -85,6 +88,29 @@ class AddressPurge extends Command
|
|||||||
$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));
|
$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));
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
$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));
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->info(sprintf('Updated [%d] filearea subscription records',$x));
|
||||||
|
|
||||||
if ($this->option('dryrun')) {
|
if ($this->option('dryrun')) {
|
||||||
$this->warn(sprintf('NOT deleting [%s] - DRY RUN',$src->ftn));
|
$this->warn(sprintf('NOT deleting [%s] - DRY RUN',$src->ftn));
|
||||||
DB::rollBack();
|
DB::rollBack();
|
@ -284,6 +284,7 @@ class SystemController extends Controller
|
|||||||
->leftjoin('zones',['zones.id'=>'addresses.zone_id'])
|
->leftjoin('zones',['zones.id'=>'addresses.zone_id'])
|
||||||
->where('addresses.system_id',$o->id)
|
->where('addresses.system_id',$o->id)
|
||||||
->where('zones.domain_id',$request->domain_id)
|
->where('zones.domain_id',$request->domain_id)
|
||||||
|
->withTrashed()
|
||||||
->FTNorder()
|
->FTNorder()
|
||||||
->get()
|
->get()
|
||||||
->map(function($item) { return ['id'=>(string)$item->id,'value'=>$item->ftn3d]; });
|
->map(function($item) { return ['id'=>(string)$item->id,'value'=>$item->ftn3d]; });
|
||||||
@ -390,6 +391,9 @@ class SystemController extends Controller
|
|||||||
if (($request->method() == 'POST') && $request->post()) {
|
if (($request->method() == 'POST') && $request->post()) {
|
||||||
session()->flash('accordion','echoarea');
|
session()->flash('accordion','echoarea');
|
||||||
|
|
||||||
|
if ($ao->trashed() && collect($request->get('id'))->diff($ao->echoareas->pluck('id'))->count())
|
||||||
|
return redirect()->back()->withErrors(sprintf('Address [%s] has been deleted, cannot add additional echos',$ao->ftn3d));
|
||||||
|
|
||||||
// Ensure we have session details for this address.
|
// Ensure we have session details for this address.
|
||||||
if (! $ao->session('sespass'))
|
if (! $ao->session('sespass'))
|
||||||
return redirect()->back()->withErrors('System doesnt belong to this network');
|
return redirect()->back()->withErrors('System doesnt belong to this network');
|
||||||
|
@ -65,6 +65,19 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@if($errors->count())
|
||||||
|
<div class="row">
|
||||||
|
<span class="btn btn-sm btn-danger" role="alert" style="text-align: left;">
|
||||||
|
There were errors with the submission.
|
||||||
|
<ul>
|
||||||
|
@foreach ($errors->all() as $error)
|
||||||
|
<li>{{ $error }}</li>
|
||||||
|
@endforeach
|
||||||
|
</ul>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12 d-none" id="echoarea-select"></div>
|
<div class="col-12 d-none" id="echoarea-select"></div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user