Add $sync parameter to send() method of Mail, SMS and Push classes #2402

This commit is contained in:
Kijin Sung 2025-03-08 20:50:18 +09:00
parent 7e9dd8f297
commit b6c444c536
3 changed files with 9 additions and 6 deletions

View file

@ -556,12 +556,13 @@ class Mail
/** /**
* Send the email. * Send the email.
* *
* @param bool $sync
* @return bool * @return bool
*/ */
public function send(): bool public function send(bool $sync = false): bool
{ {
// If queue is enabled, send asynchronously. // If queue is enabled, send asynchronously.
if (config('queue.enabled') && !defined('RXQUEUE_CRON')) if (!$sync && config('queue.enabled') && !defined('RXQUEUE_CRON'))
{ {
Queue::addTask(self::class . '::' . 'sendAsync', $this); Queue::addTask(self::class . '::' . 'sendAsync', $this);
return true; return true;

View file

@ -398,12 +398,13 @@ class Push
/** /**
* Send the message. * Send the message.
* *
* @param bool $sync
* @return bool * @return bool
*/ */
public function send(): bool public function send(bool $sync = false): bool
{ {
// If queue is enabled, send asynchronously. // If queue is enabled, send asynchronously.
if (config('queue.enabled') && !defined('RXQUEUE_CRON')) if (!$sync && config('queue.enabled') && !defined('RXQUEUE_CRON'))
{ {
Queue::addTask(self::class . '::' . 'sendAsync', $this); Queue::addTask(self::class . '::' . 'sendAsync', $this);
return true; return true;

View file

@ -507,12 +507,13 @@ class SMS
/** /**
* Send the message. * Send the message.
* *
* @param bool $sync
* @return bool * @return bool
*/ */
public function send(): bool public function send(bool $sync = false): bool
{ {
// If queue is enabled, send asynchronously. // If queue is enabled, send asynchronously.
if (config('queue.enabled') && !defined('RXQUEUE_CRON')) if (!$sync && config('queue.enabled') && !defined('RXQUEUE_CRON'))
{ {
Queue::addTask(self::class . '::' . 'sendAsync', $this); Queue::addTask(self::class . '::' . 'sendAsync', $this);
return true; return true;