Additional syntax validation for areafix/filefix commands
This commit is contained in:
parent
6dde4cf910
commit
a65e4b8bc3
@ -3,6 +3,7 @@
|
|||||||
namespace App\Classes\FTN\Process\Netmail\Robot\Areafix;
|
namespace App\Classes\FTN\Process\Netmail\Robot\Areafix;
|
||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
use Illuminate\Support\Arr;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
@ -37,18 +38,21 @@ class Area extends Base
|
|||||||
{
|
{
|
||||||
$command = self::command.' '.join(' ',$this->arguments);
|
$command = self::command.' '.join(' ',$this->arguments);
|
||||||
|
|
||||||
// If command starts with '-', its to unsubscribe
|
if (! ($area=Arr::get($this->arguments,0,NULL)))
|
||||||
if (str_starts_with($this->arguments[0],'-')) {
|
return sprintf('%-25s <-- INVALID, AN AREA IS REQUIRED',$command);
|
||||||
$sub = FALSE;
|
|
||||||
$area = substr($this->arguments[0],1);
|
|
||||||
|
|
||||||
} elseif (str_starts_with($this->arguments[0],'+')) {
|
// If command starts with '-', its to unsubscribe
|
||||||
|
if (str_starts_with($area,'-')) {
|
||||||
|
$sub = FALSE;
|
||||||
|
$area = substr($area,1);
|
||||||
|
|
||||||
|
} elseif (str_starts_with($area,'+')) {
|
||||||
$sub = TRUE;
|
$sub = TRUE;
|
||||||
$area = substr($this->arguments[0],1);
|
$area = substr($area,1);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$sub = TRUE;
|
$sub = TRUE;
|
||||||
$area = $this->arguments[0];
|
$area = $area;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log::debug(sprintf('%s:- Processing [%s] for [%s]',self::LOGKEY,$sub ? 'ADD' : 'REMOVE',$area));
|
Log::debug(sprintf('%s:- Processing [%s] for [%s]',self::LOGKEY,$sub ? 'ADD' : 'REMOVE',$area));
|
||||||
|
@ -32,29 +32,32 @@ class Rescan extends Base
|
|||||||
|
|
||||||
$command = self::command.' '.join(' ',$this->arguments);
|
$command = self::command.' '.join(' ',$this->arguments);
|
||||||
|
|
||||||
|
if (! ($area=Arr::get($this->arguments,0)))
|
||||||
|
return sprintf('%-25s <-- INVALID, AN AREA IS REQUIRED',$command);
|
||||||
|
|
||||||
if (! is_numeric($days=Arr::get($this->arguments,1,30)))
|
if (! is_numeric($days=Arr::get($this->arguments,1,30)))
|
||||||
return sprintf('%-25s <-- INVALID, DAYS [%s] NOT NUMERIC',$command,$this->arguments[1]);
|
return sprintf('%-25s <-- INVALID, DAYS [%s] NOT NUMERIC',$command,$this->arguments[1]);
|
||||||
|
|
||||||
// Area exists
|
// Area exists
|
||||||
if ($ea=$this->mo->fftn->domain->echoareas->where('name',$this->arguments[0])->pop()) {
|
if ($ea=$this->mo->fftn->domain->echoareas->where('name',$area)->pop()) {
|
||||||
// If already subscribed
|
// If already subscribed
|
||||||
if ($this->mo->fftn->echoareas->pluck('name')->contains($this->arguments[0])) {
|
if ($this->mo->fftn->echoareas->pluck('name')->contains($area)) {
|
||||||
AreafixRescan::dispatch($this->mo->fftn,$ea,$days,TRUE)
|
AreafixRescan::dispatch($this->mo->fftn,$ea,$days,TRUE)
|
||||||
->onQueue('mail');
|
->onQueue('mail');
|
||||||
|
|
||||||
Log::debug(sprintf('%s:- FTN [%s] RESCAN [%s] DAYS [%d]',self::LOGKEY,$this->mo->fftn->ftn,$this->arguments[0],$days));
|
Log::debug(sprintf('%s:- FTN [%s] RESCAN [%s] DAYS [%d]',self::LOGKEY,$this->mo->fftn->ftn,$area,$days));
|
||||||
|
|
||||||
return sprintf('%-25s <-- RESCAN [%d] DAYS queued',$command,$days);
|
return sprintf('%-25s <-- RESCAN [%d] DAYS queued',$command,$days);
|
||||||
|
|
||||||
// If not subscribed
|
// If not subscribed
|
||||||
} else {
|
} else {
|
||||||
Log::debug(sprintf('%s:- FTN [%s] is NOT subscribed to [%s], NO ACTION taken',self::LOGKEY,$this->mo->fftn->ftn,$this->arguments[0]));
|
Log::debug(sprintf('%s:- FTN [%s] is NOT subscribed to [%s], NO ACTION taken',self::LOGKEY,$this->mo->fftn->ftn,$area));
|
||||||
|
|
||||||
return sprintf('%-25s <-- NOT subscribed, NO ACTION taken',$command);
|
return sprintf('%-25s <-- NOT subscribed, NO ACTION taken',$command);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Log::debug(sprintf('%s:- FTN [%s] area UNKNOWN [%s], NO ACTION taken',self::LOGKEY,$this->mo->fftn->ftn,$this->arguments[0]));
|
Log::debug(sprintf('%s:- FTN [%s] area UNKNOWN [%s], NO ACTION taken',self::LOGKEY,$this->mo->fftn->ftn,$area));
|
||||||
|
|
||||||
return sprintf('%-25s <-- AREA UNKNOWN, NO ACTION TAKEN',$command);
|
return sprintf('%-25s <-- AREA UNKNOWN, NO ACTION TAKEN',$command);
|
||||||
}
|
}
|
||||||
|
@ -33,29 +33,32 @@ class Scan extends Base
|
|||||||
|
|
||||||
$command = self::command.' '.join(' ',$this->arguments);
|
$command = self::command.' '.join(' ',$this->arguments);
|
||||||
|
|
||||||
|
if (! ($area=Arr::get($this->arguments,0)))
|
||||||
|
return sprintf('%-25s <-- INVALID, AN AREA IS REQUIRED',$command);
|
||||||
|
|
||||||
if (! is_numeric($days=Arr::get($this->arguments,1,30)))
|
if (! is_numeric($days=Arr::get($this->arguments,1,30)))
|
||||||
return sprintf('%-25s <-- INVALID, DAYS [%s] NOT NUMERIC',$command,$this->arguments[1]);
|
return sprintf('%-25s <-- INVALID, DAYS [%s] NOT NUMERIC',$command,$this->arguments[1]);
|
||||||
|
|
||||||
// Area exists
|
// Area exists
|
||||||
if ($ea=$this->mo->fftn->domain->echoareas->where('name',$this->arguments[0])->pop()) {
|
if ($ea=$this->mo->fftn->domain->echoareas->where('name',$area)->pop()) {
|
||||||
// If already subscribed
|
// If already subscribed
|
||||||
if ($this->mo->fftn->echoareas->pluck('name')->contains($this->arguments[0])) {
|
if ($this->mo->fftn->echoareas->pluck('name')->contains($area)) {
|
||||||
AreafixRescan::dispatch($this->mo->fftn,$ea,$days)
|
AreafixRescan::dispatch($this->mo->fftn,$ea,$days)
|
||||||
->onQueue('mail');
|
->onQueue('mail');
|
||||||
|
|
||||||
Log::debug(sprintf('%s:- FTN [%s] SCAN [%s] DAYS [%d]',self::LOGKEY,$this->mo->fftn->ftn,$this->arguments[0],$days));
|
Log::debug(sprintf('%s:- FTN [%s] SCAN [%s] DAYS [%d]',self::LOGKEY,$this->mo->fftn->ftn,$area,$days));
|
||||||
|
|
||||||
return sprintf('%-25s <-- SCAN [%d] DAYS queued',$command,$days);
|
return sprintf('%-25s <-- SCAN [%d] DAYS queued',$command,$days);
|
||||||
|
|
||||||
// If not subscribed
|
// If not subscribed
|
||||||
} else {
|
} else {
|
||||||
Log::debug(sprintf('%s:- FTN [%s] is NOT subscribed to [%s], NO ACTION taken',self::LOGKEY,$this->mo->fftn->ftn,$this->arguments[0]));
|
Log::debug(sprintf('%s:- FTN [%s] is NOT subscribed to [%s], NO ACTION taken',self::LOGKEY,$this->mo->fftn->ftn,$area));
|
||||||
|
|
||||||
return sprintf('%-25s <-- NOT subscribed, NO ACTION taken',$command);
|
return sprintf('%-25s <-- NOT subscribed, NO ACTION taken',$command);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Log::debug(sprintf('%s:- FTN [%s] area UNKNOWN [%s], NO ACTION taken',self::LOGKEY,$this->mo->fftn->ftn,$this->arguments[0]));
|
Log::debug(sprintf('%s:- FTN [%s] area UNKNOWN [%s], NO ACTION taken',self::LOGKEY,$this->mo->fftn->ftn,$area));
|
||||||
|
|
||||||
return sprintf('%-25s <-- AREA UNKNOWN, NO ACTION TAKEN',$command);
|
return sprintf('%-25s <-- AREA UNKNOWN, NO ACTION TAKEN',$command);
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
namespace App\Classes\FTN\Process\Netmail\Robot\Filefix;
|
namespace App\Classes\FTN\Process\Netmail\Robot\Filefix;
|
||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
use Illuminate\Support\Arr;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
@ -38,18 +39,21 @@ class Area extends Base
|
|||||||
{
|
{
|
||||||
$command = self::command.' '.join(' ',$this->arguments);
|
$command = self::command.' '.join(' ',$this->arguments);
|
||||||
|
|
||||||
// If command starts with '-', its to unsubscribe
|
if (! ($area=Arr::get($this->arguments,0,NULL)))
|
||||||
if (str_starts_with($this->arguments[0],'-')) {
|
return sprintf('%-25s <-- INVALID, AN AREA IS REQUIRED',$command);
|
||||||
$sub = FALSE;
|
|
||||||
$area = substr($this->arguments[0],1);
|
|
||||||
|
|
||||||
} elseif (str_starts_with($this->arguments[0],'+')) {
|
// If command starts with '-', its to unsubscribe
|
||||||
|
if (str_starts_with($area,'-')) {
|
||||||
|
$sub = FALSE;
|
||||||
|
$area = substr($area,1);
|
||||||
|
|
||||||
|
} elseif (str_starts_with($area,'+')) {
|
||||||
$sub = TRUE;
|
$sub = TRUE;
|
||||||
$area = substr($this->arguments[0],1);
|
$area = substr($area,1);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$sub = TRUE;
|
$sub = TRUE;
|
||||||
$area = $this->arguments[0];
|
$area = $area;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log::debug(sprintf('%s:- Processing [%s] for [%s]',self::LOGKEY,$sub ? 'ADD' : 'REMOVE',$area));
|
Log::debug(sprintf('%s:- Processing [%s] for [%s]',self::LOGKEY,$sub ? 'ADD' : 'REMOVE',$area));
|
||||||
|
@ -34,6 +34,9 @@ class Rescan extends Base
|
|||||||
|
|
||||||
$command = self::command.' '.join(' ',$this->arguments);
|
$command = self::command.' '.join(' ',$this->arguments);
|
||||||
|
|
||||||
|
if (! ($area=Arr::get($this->arguments,0)))
|
||||||
|
return sprintf('%-25s <-- INVALID, AN AREA IS REQUIRED',$command);
|
||||||
|
|
||||||
if (! is_numeric($days=Arr::get($this->arguments,1,30)))
|
if (! is_numeric($days=Arr::get($this->arguments,1,30)))
|
||||||
return sprintf('%-25s <-- INVALID, DAYS [%s] NOT NUMERIC',$command,$this->arguments[1]);
|
return sprintf('%-25s <-- INVALID, DAYS [%s] NOT NUMERIC',$command,$this->arguments[1]);
|
||||||
|
|
||||||
@ -41,25 +44,25 @@ class Rescan extends Base
|
|||||||
$days = 365;
|
$days = 365;
|
||||||
|
|
||||||
// Area exists
|
// Area exists
|
||||||
if ($fa=$this->mo->fftn->domain->fileareas->where('name',$this->arguments[0])->pop()) {
|
if ($fa=$this->mo->fftn->domain->fileareas->where('name',$area)->pop()) {
|
||||||
// If already subscribed
|
// If already subscribed
|
||||||
if ($this->mo->fftn->fileareas->pluck('name')->contains($this->arguments[0])) {
|
if ($this->mo->fftn->fileareas->pluck('name')->contains($area)) {
|
||||||
FilefixRescan::dispatch($this->mo->fftn,$fa,$days,TRUE)
|
FilefixRescan::dispatch($this->mo->fftn,$fa,$days,TRUE)
|
||||||
->onQueue('mail');
|
->onQueue('mail');
|
||||||
|
|
||||||
Log::debug(sprintf('%s:- FTN [%s] RESCAN [%s] DAYS [%d]',self::LOGKEY,$this->mo->fftn->ftn,$this->arguments[0],$days));
|
Log::debug(sprintf('%s:- FTN [%s] RESCAN [%s] DAYS [%d]',self::LOGKEY,$this->mo->fftn->ftn,$area,$days));
|
||||||
|
|
||||||
return sprintf('%-25s <-- RESCAN [%d] DAYS queued',$command,$days);
|
return sprintf('%-25s <-- RESCAN [%d] DAYS queued',$command,$days);
|
||||||
|
|
||||||
// If not subscribed
|
// If not subscribed
|
||||||
} else {
|
} else {
|
||||||
Log::debug(sprintf('%s:- FTN [%s] is NOT subscribed to [%s], NO ACTION taken',self::LOGKEY,$this->mo->fftn->ftn,$this->arguments[0]));
|
Log::debug(sprintf('%s:- FTN [%s] is NOT subscribed to [%s], NO ACTION taken',self::LOGKEY,$this->mo->fftn->ftn,$area));
|
||||||
|
|
||||||
return sprintf('%-25s <-- NOT subscribed, NO ACTION taken',$command);
|
return sprintf('%-25s <-- NOT subscribed, NO ACTION taken',$command);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Log::debug(sprintf('%s:- FILE [%s] area UNKNOWN [%s], NO ACTION taken',self::LOGKEY,$this->mo->fftn->ftn,$this->arguments[0]));
|
Log::debug(sprintf('%s:- FILE [%s] area UNKNOWN [%s], NO ACTION taken',self::LOGKEY,$this->mo->fftn->ftn,$area));
|
||||||
|
|
||||||
return sprintf('%-25s <-- AREA UNKNOWN, NO ACTION TAKEN',$command);
|
return sprintf('%-25s <-- AREA UNKNOWN, NO ACTION TAKEN',$command);
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,9 @@ class Scan extends Base
|
|||||||
|
|
||||||
$command = self::command.' '.join(' ',$this->arguments);
|
$command = self::command.' '.join(' ',$this->arguments);
|
||||||
|
|
||||||
|
if (! ($area=Arr::get($this->arguments,0)))
|
||||||
|
return sprintf('%-25s <-- INVALID, AN AREA IS REQUIRED',$command);
|
||||||
|
|
||||||
if (! is_numeric($days=Arr::get($this->arguments,1,30)))
|
if (! is_numeric($days=Arr::get($this->arguments,1,30)))
|
||||||
return sprintf('%-25s <-- INVALID, DAYS [%s] NOT NUMERIC',$command,$this->arguments[1]);
|
return sprintf('%-25s <-- INVALID, DAYS [%s] NOT NUMERIC',$command,$this->arguments[1]);
|
||||||
|
|
||||||
@ -41,25 +44,25 @@ class Scan extends Base
|
|||||||
$days = 365;
|
$days = 365;
|
||||||
|
|
||||||
// Area exists
|
// Area exists
|
||||||
if ($fa=$this->mo->fftn->domain->fileareas->where('name',$this->arguments[0])->pop()) {
|
if ($fa=$this->mo->fftn->domain->fileareas->where('name',$area)->pop()) {
|
||||||
// If already subscribed
|
// If already subscribed
|
||||||
if ($this->mo->fftn->fileareas->pluck('name')->contains($this->arguments[0])) {
|
if ($this->mo->fftn->fileareas->pluck('name')->contains($area)) {
|
||||||
FilefixRescan::dispatch($this->mo->fftn,$fa,$days)
|
FilefixRescan::dispatch($this->mo->fftn,$fa,$days)
|
||||||
->onQueue('mail');
|
->onQueue('mail');
|
||||||
|
|
||||||
Log::debug(sprintf('%s:- FTN [%s] SCAN [%s] DAYS [%d]',self::LOGKEY,$this->mo->fftn->ftn,$this->arguments[0],$days));
|
Log::debug(sprintf('%s:- FTN [%s] SCAN [%s] DAYS [%d]',self::LOGKEY,$this->mo->fftn->ftn,$area,$days));
|
||||||
|
|
||||||
return sprintf('%-25s <-- SCAN [%d] DAYS queued',$command,$days);
|
return sprintf('%-25s <-- SCAN [%d] DAYS queued',$command,$days);
|
||||||
|
|
||||||
// If not subscribed
|
// If not subscribed
|
||||||
} else {
|
} else {
|
||||||
Log::debug(sprintf('%s:- FTN [%s] is NOT subscribed to [%s], NO ACTION taken',self::LOGKEY,$this->mo->fftn->ftn,$this->arguments[0]));
|
Log::debug(sprintf('%s:- FTN [%s] is NOT subscribed to [%s], NO ACTION taken',self::LOGKEY,$this->mo->fftn->ftn,$area));
|
||||||
|
|
||||||
return sprintf('%-25s <-- NOT subscribed, NO ACTION taken',$command);
|
return sprintf('%-25s <-- NOT subscribed, NO ACTION taken',$command);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Log::debug(sprintf('%s:- FILE [%s] area UNKNOWN [%s], NO ACTION taken',self::LOGKEY,$this->mo->fftn->ftn,$this->arguments[0]));
|
Log::debug(sprintf('%s:- FILE [%s] area UNKNOWN [%s], NO ACTION taken',self::LOGKEY,$this->mo->fftn->ftn,$area));
|
||||||
|
|
||||||
return sprintf('%-25s <-- AREA UNKNOWN, NO ACTION TAKEN',$command);
|
return sprintf('%-25s <-- AREA UNKNOWN, NO ACTION TAKEN',$command);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user