From 7a56a3727a7924ed4afed14cea685ff0d23f5686 Mon Sep 17 00:00:00 2001 From: Denis Mysenko Date: Sun, 27 Nov 2022 14:54:02 +1100 Subject: [PATCH] + custom queued handler --- src/Jobs/CallQueuedHandler.php | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/Jobs/CallQueuedHandler.php b/src/Jobs/CallQueuedHandler.php index d33e330..92e20c1 100644 --- a/src/Jobs/CallQueuedHandler.php +++ b/src/Jobs/CallQueuedHandler.php @@ -16,27 +16,23 @@ class CallQueuedHandler extends LaravelHandler { */ protected function dispatchThroughMiddleware(Job $job, $command) { - if ($this->hasExpired($command, $job->timestamp())) { - throw new ExpiredJobException("This job has already expired"); + if (property_exists($command, 'class') && $this->hasExpired($command->class, $job->timestamp())) { + throw new ExpiredJobException("Job {$command->class} has already expired"); } return parent::dispatchThroughMiddleware($job, $command); } /** - * @param $command + * @param $className * @param $queuedAt * @return bool */ - protected function hasExpired($command, $queuedAt) { - if (! property_exists($command, 'class')) { + protected function hasExpired($className, $queuedAt) { + if (! property_exists($className, 'retention')) { return false; } - if (! property_exists($command->class, 'retention')) { - return false; - } - - return time() > $queuedAt + $command->class::$retention; + return time() > $queuedAt + $className::$retention; } }