2024-10-31 23:04:12 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Classes\FTN\Process\Netmail\Robot\Areafix;
|
|
|
|
|
2024-11-28 11:07:39 +00:00
|
|
|
use Illuminate\Support\Arr;
|
2024-10-31 23:04:12 +00:00
|
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
|
|
|
|
use App\Jobs\AreafixRescan;
|
|
|
|
|
|
|
|
// SCAN - Send unsent echomail
|
|
|
|
class Scan extends Base
|
|
|
|
{
|
|
|
|
private const LOGKEY = 'AFS';
|
|
|
|
private const command = '%SCAN';
|
|
|
|
|
|
|
|
public static function help(): array
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
self::command.' [-|+]<ECHOAREA> [<DAYS>]',
|
|
|
|
' Use the scan command to resend mail that you havent received yet from an',
|
|
|
|
' echoarea. This is useful if you are rejoining an echoarea, and only want',
|
|
|
|
' to get mail that you dont already have.',
|
|
|
|
' Arguments:',
|
|
|
|
' - ECHOAREA (required) name of area to subscribe or unsubscribe',
|
|
|
|
' - DAYS (optional) number of days to resend mail from this area that you',
|
2024-11-28 11:07:39 +00:00
|
|
|
' If DAYS is omitted, the default is 30.',
|
2024-10-31 23:04:12 +00:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function process(): string
|
|
|
|
{
|
2024-11-01 13:10:38 +00:00
|
|
|
Log::debug(sprintf('%s:- Areafix [%s] for [%s] for [%s]',self::LOGKEY,self::command,$this->mo->fftn->ftn,join('|',$this->arguments)));
|
2024-10-31 23:04:12 +00:00
|
|
|
|
|
|
|
$command = self::command.' '.join(' ',$this->arguments);
|
|
|
|
|
2024-11-28 11:07:39 +00:00
|
|
|
if (! is_numeric($days=Arr::get($this->arguments,1,30)))
|
2024-10-31 23:04:12 +00:00
|
|
|
return sprintf('%-25s <-- INVALID, DAYS [%s] NOT NUMERIC',$command,$this->arguments[1]);
|
|
|
|
|
|
|
|
// Area exists
|
|
|
|
if ($ea=$this->mo->fftn->domain->echoareas->where('name',$this->arguments[0])->pop()) {
|
|
|
|
// If already subscribed
|
|
|
|
if ($this->mo->fftn->echoareas->pluck('name')->contains($this->arguments[0])) {
|
2024-11-28 11:07:39 +00:00
|
|
|
AreafixRescan::dispatch($this->mo->fftn,$ea,$days)
|
2024-10-31 23:04:12 +00:00
|
|
|
->onQueue('mail');
|
|
|
|
|
2024-11-28 11:07:39 +00:00
|
|
|
Log::debug(sprintf('%s:- FTN [%s] SCAN [%s] DAYS [%d]',self::LOGKEY,$this->mo->fftn->ftn,$this->arguments[0],$days));
|
2024-11-01 13:10:38 +00:00
|
|
|
|
2024-11-28 11:07:39 +00:00
|
|
|
return sprintf('%-25s <-- SCAN [%d] DAYS queued',$command,$days);
|
2024-10-31 23:04:12 +00:00
|
|
|
|
|
|
|
// 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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|