Compare commits

..

2 Commits

Author SHA1 Message Date
adadbef249 Implemented filefix %RESEND
All checks were successful
Create Docker Image / Build Docker Image (x86_64) (push) Successful in 40s
Create Docker Image / Build Docker Image (arm64) (push) Successful in 1m33s
Create Docker Image / Final Docker Image Manifest (push) Successful in 11s
2024-11-28 23:20:17 +11:00
19daab24ff Implemented filefix %SCAN/%RESCAN, and some cosmetic cleanup 2024-11-28 23:20:17 +11:00
4 changed files with 84 additions and 5 deletions

View File

@ -62,9 +62,9 @@ class Area extends Base
if ($nea=$this->mo->fftn->echoareas->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 {

View File

@ -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 {

View File

@ -0,0 +1,79 @@
<?php
namespace App\Classes\FTN\Process\Netmail\Robot\Filefix;
use Carbon\Carbon;
use Illuminate\Support\Facades\Log;
use App\Classes\FTN\Process\Netmail\Robot\Areafix\Base;
// Resend a file
class Resend extends Base
{
private const LOGKEY = 'FFA';
private const command = '%RESEND';
public static function help(): array
{
return [
self::command.' <FILEAREA> <FILENAME>',
' Resend a file from a file area',
' Arguments:',
' - FILEAREA (required) name of area to subscribe or unsubscribe',
' - FILENAME (required) number of file to resend',
' Notes:',
' * You can obtain a list of files in an area with %FILELIST <FILEAREA>',
];
}
public function process(): string
{
$command = self::command.' '.join(' ',$this->arguments);
if (count($this->arguments) < 2)
return sprintf('%-25s <-- INVALID, NOT ENOUGH ARGUMENTS',$command);
elseif (count($this->arguments) > 2)
return sprintf('%-25s <-- INVALID, TOO MANU ARGUMENTS',$command);
Log::debug(sprintf('%s:- Resending [%s] from [%s] to [%s]',self::LOGKEY,$this->arguments[1],$this->arguments[0],$this->mo->fftn->ftn));
// Area exists
if ($fa=$this->mo->fftn->domain->fileareas->where('name',$this->arguments[0])->pop()) {
// If already subscribed
if ($nea=$this->mo->fftn->fileareas->where('name',$fa->name)->pop()) {
// Check the file is in the area
if ($fo=$nea->files()->where('name','ilike',$this->arguments[1])->single()) {
// File hasnt been exported before
if (! $fo->seenby->where('id',$this->mo->fftn_id)->count()) {
Log::info(sprintf('Exported [%d] FILE (%s) dated (%s) to [%s]',$fo->id,$fo->name,$fo->datetime->format('Y-m-d H:i:s'),$this->mo->fftn->ftn3d));
$fo->seenby()->attach($this->mo->fftn_id,['export_at'=>Carbon::now()]);
} else {
Log::debug(sprintf('Re-exported [%d] FILE (%s) dated (%s) to [%s]',$fo->id,$fo->name,$fo->datetime,$this->mo->fftn->ftn3d));
$fo->seenby()->updateExistingPivot($this->mo->fftn_id,['export_at'=>Carbon::now(),'sent_at'=>NULL]);
}
return sprintf('%-25s <-- FILE QUEUED TO RESEND',$command);
// No file in area
} else {
Log::debug(sprintf('%s:- FTN [%s] doesnt have a file [%s], NO ACTION taken',self::LOGKEY,$this->mo->fftn->ftn,$this->arguments[1]));
return sprintf('%-25s <-- FILE NOT FOUND, NO ACTION taken',$command);
}
// 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);
}
}
}

View File

@ -95,7 +95,7 @@ class FilefixRescan implements ShouldQueue
->cursor() as $fo)
{
// File hasnt been exported before
if (! $fo->seenby->count()) {
if (! $fo->seenby->where('address_id',$this->ao->id)->count()) {
$fo->seenby()->attach($this->ao->id,['export_at'=>Carbon::now()]);
$c++;