mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-05 17:51:40 +09:00
Integrate Mail and SMS with Queue
This commit is contained in:
parent
f6a458f648
commit
a1abf5016f
2 changed files with 36 additions and 0 deletions
|
|
@ -560,6 +560,13 @@ class Mail
|
|||
*/
|
||||
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']))
|
||||
|
|
@ -600,6 +607,17 @@ class Mail
|
|||
return $this->sent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send an email asynchronously (for Queue integration).
|
||||
*
|
||||
* @param self $mail
|
||||
* @return void
|
||||
*/
|
||||
public static function sendAsync(self $mail): void
|
||||
{
|
||||
$mail->send();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the message was sent.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -511,6 +511,13 @@ class SMS
|
|||
*/
|
||||
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']))
|
||||
|
|
@ -566,6 +573,17 @@ class SMS
|
|||
return $this->sent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send an SMS asynchronously (for Queue integration).
|
||||
*
|
||||
* @param self $sms
|
||||
* @return void
|
||||
*/
|
||||
public static function sendAsync(self $sms): void
|
||||
{
|
||||
$sms->send();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the message was sent.
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue