Implemented filefix %SCAN/%RESCAN, and some cosmetic cleanup
This commit is contained in:
@@ -63,9 +63,9 @@ class Area extends Base
|
||||
if ($nea=$this->mo->fftn->fileareas->where('name',$area)->pop()) {
|
||||
// requesting to subscribe "You already are since..., arguments ignored
|
||||
if ($sub) {
|
||||
Log::debug(sprintf('%s:- FTN [%s] ALREADY subscribed to [%s] since [%s]',self::LOGKEY,$this->mo->fftn->ftn,$area,$nea->pivot->subscribed->format('Y-m-d H:i')));
|
||||
Log::debug(sprintf('%s:- FTN [%s] ALREADY subscribed to [%s] since [%s]',self::LOGKEY,$this->mo->fftn->ftn,$area,$nea->pivot->subscribed));
|
||||
|
||||
return sprintf('%-25s <-- ALREADY subscribed since %s',$command,$nea->pivot->subscribed->format('Y-m-d H:i'));
|
||||
return sprintf('%-25s <-- ALREADY subscribed since %s',$command,$nea->pivot->subscribed);
|
||||
|
||||
// requesting to unsubscribe
|
||||
} else {
|
||||
@@ -87,7 +87,7 @@ class Area extends Base
|
||||
return sprintf('%-25s <-- UNSUBSCRIBED, CLEARED [%d] FILES from queue',$command,$x);
|
||||
}
|
||||
|
||||
// If not subscribed
|
||||
// If not subscribed
|
||||
} else {
|
||||
// requesting to subscribe, subsubsribe and rescan if arguments
|
||||
if ($sub) {
|
||||
@@ -136,7 +136,7 @@ class Area extends Base
|
||||
}
|
||||
|
||||
} else {
|
||||
Log::debug(sprintf('%s:- FTN [%s] area UNKNOWN [%s], NO ACTION taken',self::LOGKEY,$this->mo->fftn->ftn,$area));
|
||||
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);
|
||||
}
|
||||
|
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Classes\FTN\Process\Netmail\Robot\Filefix;
|
||||
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
|
||||
@@ -34,22 +35,22 @@ class Filelist extends Base
|
||||
|
||||
$command = self::command.' '.join(' ',$this->arguments);
|
||||
|
||||
if (! is_numeric($this->arguments[1]))
|
||||
if (! is_numeric($days=Arr::get($this->arguments,1,30)))
|
||||
return sprintf('%-25s <-- INVALID, DAYS [%s] NOT NUMERIC',$command,$this->arguments[1]);
|
||||
|
||||
if ($this->arguments[1] > 365)
|
||||
$this->arguments[1] = 365;
|
||||
if ($days > 365)
|
||||
$days = 365;
|
||||
|
||||
// Area exists
|
||||
if ($fa=$this->mo->fftn->domain->fileareas->where('name',$this->arguments[0])->pop()) {
|
||||
// If already subscribed
|
||||
if ($this->mo->fftn->fileareas->pluck('name')->contains($this->arguments[0])) {
|
||||
Notification::route('netmail',$this->mo->fftn)
|
||||
->notify(new FileListNotification($this->mo,$fa,$this->arguments[1]));
|
||||
->notify(new FileListNotification($this->mo,$fa,$days));
|
||||
|
||||
Log::debug(sprintf('%s:- FTN [%s] FILELIST [%s] DAYS [%d]',self::LOGKEY,$this->mo->fftn->ftn,$this->arguments[0],$this->arguments[1]));
|
||||
Log::debug(sprintf('%s:- FTN [%s] FILELIST [%s] DAYS [%d]',self::LOGKEY,$this->mo->fftn->ftn,$this->arguments[0],$days));
|
||||
|
||||
return sprintf('%-25s <-- FILELIST [%d] DAYS',$command,$this->arguments[1]);
|
||||
return sprintf('%-25s <-- FILELIST [%d] DAYS',$command,$days);
|
||||
|
||||
// If not subscribed
|
||||
} else {
|
||||
@@ -59,7 +60,7 @@ class Filelist extends Base
|
||||
}
|
||||
|
||||
} 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:- FILE [%s] area UNKNOWN [%s], NO ACTION taken',self::LOGKEY,$this->mo->fftn->ftn,$this->arguments[0]));
|
||||
|
||||
return sprintf('%-25s <-- AREA UNKNOWN, NO ACTION TAKEN',$command);
|
||||
}
|
||||
|
67
app/Classes/FTN/Process/Netmail/Robot/Filefix/Rescan.php
Normal file
67
app/Classes/FTN/Process/Netmail/Robot/Filefix/Rescan.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\FTN\Process\Netmail\Robot\Filefix;
|
||||
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
use App\Classes\FTN\Process\Netmail\Robot\Areafix\Base;
|
||||
use App\Jobs\FilefixRescan;
|
||||
|
||||
// RESCAN - Resend echomail
|
||||
class Rescan extends Base
|
||||
{
|
||||
private const LOGKEY = 'AFR';
|
||||
private const command = '%RESCAN';
|
||||
|
||||
public static function help(): array
|
||||
{
|
||||
return [
|
||||
self::command.' [-|+]<FILEAREA> [<DAYS>]',
|
||||
' Use the rescan command to resend files from a filearea.',
|
||||
' This is will resend files again, even if you have received them in the',
|
||||
' past.',
|
||||
' Arguments:',
|
||||
' - FILEAREA (required) name of area to subscribe or unsubscribe',
|
||||
' - DAYS (optional) number of days to resend mail from this area that you',
|
||||
' If DAYS is omitted, the default is 30. The maximum is 365.',
|
||||
];
|
||||
}
|
||||
|
||||
public function process(): string
|
||||
{
|
||||
Log::debug(sprintf('%s:- Filefix [%s] for [%s] for [%s]',self::LOGKEY,self::command,$this->mo->fftn->ftn,join('|',$this->arguments)));
|
||||
|
||||
$command = self::command.' '.join(' ',$this->arguments);
|
||||
|
||||
if (! is_numeric($days=Arr::get($this->arguments,1,30)))
|
||||
return sprintf('%-25s <-- INVALID, DAYS [%s] NOT NUMERIC',$command,$this->arguments[1]);
|
||||
|
||||
if ($days > 365)
|
||||
$days = 365;
|
||||
|
||||
// Area exists
|
||||
if ($fa=$this->mo->fftn->domain->fileareas->where('name',$this->arguments[0])->pop()) {
|
||||
// If already subscribed
|
||||
if ($this->mo->fftn->fileareas->pluck('name')->contains($this->arguments[0])) {
|
||||
FilefixRescan::dispatch($this->mo->fftn,$fa,$days,TRUE)
|
||||
->onQueue('mail');
|
||||
|
||||
Log::debug(sprintf('%s:- FTN [%s] RESCAN [%s] DAYS [%d]',self::LOGKEY,$this->mo->fftn->ftn,$this->arguments[0],$days));
|
||||
|
||||
return sprintf('%-25s <-- RESCAN [%d] DAYS queued',$command,$days);
|
||||
|
||||
// If not subscribed
|
||||
} else {
|
||||
Log::debug(sprintf('%s:- FTN [%s] is NOT subscribed to [%s], NO ACTION taken',self::LOGKEY,$this->mo->fftn->ftn,$this->arguments[0]));
|
||||
|
||||
return sprintf('%-25s <-- NOT subscribed, NO ACTION taken',$command);
|
||||
}
|
||||
|
||||
} else {
|
||||
Log::debug(sprintf('%s:- FILE [%s] area UNKNOWN [%s], NO ACTION taken',self::LOGKEY,$this->mo->fftn->ftn,$this->arguments[0]));
|
||||
|
||||
return sprintf('%-25s <-- AREA UNKNOWN, NO ACTION TAKEN',$command);
|
||||
}
|
||||
}
|
||||
}
|
67
app/Classes/FTN/Process/Netmail/Robot/Filefix/Scan.php
Normal file
67
app/Classes/FTN/Process/Netmail/Robot/Filefix/Scan.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\FTN\Process\Netmail\Robot\Filefix;
|
||||
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
use App\Classes\FTN\Process\Netmail\Robot\Areafix\Base;
|
||||
use App\Jobs\FilefixRescan;
|
||||
|
||||
// SCAN - Send unsent echomail
|
||||
class Scan extends Base
|
||||
{
|
||||
private const LOGKEY = 'AFS';
|
||||
private const command = '%SCAN';
|
||||
|
||||
public static function help(): array
|
||||
{
|
||||
return [
|
||||
self::command.' [-|+]<FILEAREA> [<DAYS>]',
|
||||
' Use the scan command to resend files that you havent received yet from an',
|
||||
' filearea. This is useful if you are rejoining an filearea, and only want',
|
||||
' to get files that you dont already have.',
|
||||
' Arguments:',
|
||||
' - FILEAREA (required) name of area to subscribe or unsubscribe',
|
||||
' - DAYS (optional) number of days to resend mail from this area that you',
|
||||
' If DAYS is omitted, the default is 30. The maximum is 365.',
|
||||
];
|
||||
}
|
||||
|
||||
public function process(): string
|
||||
{
|
||||
Log::debug(sprintf('%s:- Filefix [%s] for [%s] for [%s]',self::LOGKEY,self::command,$this->mo->fftn->ftn,join('|',$this->arguments)));
|
||||
|
||||
$command = self::command.' '.join(' ',$this->arguments);
|
||||
|
||||
if (! is_numeric($days=Arr::get($this->arguments,1,30)))
|
||||
return sprintf('%-25s <-- INVALID, DAYS [%s] NOT NUMERIC',$command,$this->arguments[1]);
|
||||
|
||||
if ($days > 365)
|
||||
$days = 365;
|
||||
|
||||
// Area exists
|
||||
if ($fa=$this->mo->fftn->domain->fileareas->where('name',$this->arguments[0])->pop()) {
|
||||
// If already subscribed
|
||||
if ($this->mo->fftn->fileareas->pluck('name')->contains($this->arguments[0])) {
|
||||
FilefixRescan::dispatch($this->mo->fftn,$fa,$days)
|
||||
->onQueue('mail');
|
||||
|
||||
Log::debug(sprintf('%s:- FTN [%s] SCAN [%s] DAYS [%d]',self::LOGKEY,$this->mo->fftn->ftn,$this->arguments[0],$days));
|
||||
|
||||
return sprintf('%-25s <-- SCAN [%d] DAYS queued',$command,$days);
|
||||
|
||||
// If not subscribed
|
||||
} else {
|
||||
Log::debug(sprintf('%s:- FTN [%s] is NOT subscribed to [%s], NO ACTION taken',self::LOGKEY,$this->mo->fftn->ftn,$this->arguments[0]));
|
||||
|
||||
return sprintf('%-25s <-- NOT subscribed, NO ACTION taken',$command);
|
||||
}
|
||||
|
||||
} else {
|
||||
Log::debug(sprintf('%s:- FILE [%s] area UNKNOWN [%s], NO ACTION taken',self::LOGKEY,$this->mo->fftn->ftn,$this->arguments[0]));
|
||||
|
||||
return sprintf('%-25s <-- AREA UNKNOWN, NO ACTION TAKEN',$command);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user