clrghouz/app/Classes/FTN/Process/Netmail/Robot/Filefix/Rescan.php
Deon George f0f640b347
All checks were successful
Create Docker Image / Build Docker Image (x86_64) (push) Successful in 38s
Create Docker Image / Build Docker Image (arm64) (push) Successful in 1m32s
Create Docker Image / Final Docker Image Manifest (push) Successful in 10s
Implemented filefix %SCAN/%RESCAN, and some cosmetic cleanup
2024-11-28 22:07:39 +11:00

67 lines
2.2 KiB
PHP

<?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:- FTN [%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);
}
}
}