From 3dc18a3f1f1ada22e1f056711688662118d4560e Mon Sep 17 00:00:00 2001 From: Deon George Date: Wed, 25 Jan 2023 16:26:10 +1100 Subject: [PATCH] Change default internal caching to off, and added test to make sure things are cached if on. More debugging with packet name for netmails --- app/Classes/FTN/Packet.php | 8 +++++--- app/Console/Commands/PacketProcess.php | 3 +-- app/Jobs/MessageProcess.php | 7 +++++++ 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/app/Classes/FTN/Packet.php b/app/Classes/FTN/Packet.php index ba1c46a..dc26d11 100644 --- a/app/Classes/FTN/Packet.php +++ b/app/Classes/FTN/Packet.php @@ -58,7 +58,7 @@ class Packet extends FTNBase implements \Iterator, \Countable public Collection $messages; // Messages in the Packet public Collection $errors; // Messages that fail validation private string $name; // Packet name - public bool $use_cache = TRUE; // Use a cache for messages. + public bool $use_cache = FALSE; // Use a cache for messages. private int $index; // Our array index /** @@ -124,7 +124,7 @@ class Packet extends FTNBase implements \Iterator, \Countable * @throws InvalidPacketException */ - public static function process(mixed $f,string $name,int $size,System $system=NULL,bool $use_cache=TRUE): self + public static function process(mixed $f,string $name,int $size,System $system=NULL,bool $use_cache=FALSE): self { Log::debug(sprintf('%s:+ Opening Packet [%s] with size [%d]',self::LOGKEY,$name,$size)); @@ -523,7 +523,9 @@ class Packet extends FTNBase implements \Iterator, \Countable if ($this->use_cache) { $key = urlencode($msg->msgid ?: sprintf('%s %s',$msg->fftn,Carbon::now()->timestamp)); - Cache::forever($key,serialize($msg)); + if (! Cache::forever($key,serialize($msg))) + throw new \Exception(sprintf('Caching failed for key [%s]?',$key)); + $this->messages->push($key); } else { diff --git a/app/Console/Commands/PacketProcess.php b/app/Console/Commands/PacketProcess.php index ea66ce1..328ac1d 100644 --- a/app/Console/Commands/PacketProcess.php +++ b/app/Console/Commands/PacketProcess.php @@ -3,7 +3,6 @@ namespace App\Console\Commands; use Illuminate\Console\Command; -use Illuminate\Support\Arr; use App\Classes\File; use App\Classes\FTN\Packet; @@ -45,7 +44,7 @@ class PacketProcess extends Command // @todo Quick check that the packet should be processed by us. // @todo validate that the packet's zone is in the domain. - $this->info(sprintf('Processing message from [%s] with msgid [%s]',$msg->fboss,$msg->msgid)); + $this->info(sprintf('Processing message from [%s] with msgid [%s] in (%s)',$msg->fboss,$msg->msgid,$f->pktName())); // Dispatch job. Job::dispatchSync($msg,$f->pktName(),$this->option('nobot')); diff --git a/app/Jobs/MessageProcess.php b/app/Jobs/MessageProcess.php index 73b8c21..7deca6d 100644 --- a/app/Jobs/MessageProcess.php +++ b/app/Jobs/MessageProcess.php @@ -41,6 +41,13 @@ class MessageProcess implements ShouldQueue // If we are a netmail if ($this->msg->isNetmail()) { + Log::info(sprintf('%s:Processing Netmail [%s] to (%s) [%s] from (%s) [%s].', + self::LOGKEY, + $this->msg->msgid, + $this->msg->user_to,$this->msg->tftn, + $this->msg->user_from,$this->msg->fftn, + )); + // @todo Enable checks to reject old messages // @todo Enable checks to reject duplicate // @todo Enable checks to see if this is a file request or file send