From b4e7d4aaad2ecd7f814d94ccaf0692582f22b370 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Thu, 10 Oct 2024 23:54:53 +0900 Subject: [PATCH] Integrate Push with Queue --- common/framework/Push.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/common/framework/Push.php b/common/framework/Push.php index 547a2295e..bc37cd2c7 100644 --- a/common/framework/Push.php +++ b/common/framework/Push.php @@ -402,6 +402,13 @@ class Push */ public function send(): bool { + // If queue is enabled, send asynchronously. + if (config('queue.enabled') && !defined('RXQUEUE_CRON')) + { + Queue::addTask(self::class . '::' . 'sendAsync', $this); + return true; + } + // Get caller information. $backtrace = debug_backtrace(0); if(count($backtrace) && isset($backtrace[0]['file'])) @@ -464,6 +471,17 @@ class Push return $this->sent > 0 ? true : false; } + /** + * Send asynchronously (for Queue integration). + * + * @param self $sms + * @return void + */ + public static function sendAsync(self $push): void + { + $push->send(); + } + /** * Get the device token *