Integrate Push with Queue

This commit is contained in:
Kijin Sung 2024-10-10 23:54:53 +09:00
parent a1abf5016f
commit b4e7d4aaad

View file

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