mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-04-25 21:32:51 +09:00
Implement delayed sending of SMS
This commit is contained in:
parent
bffe96456d
commit
0b01c52d98
2 changed files with 48 additions and 1 deletions
|
|
@ -67,9 +67,18 @@ class CoolSMS extends Base implements \Rhymix\Framework\Drivers\SMSInterface
|
|||
$options->from = $message->getFrom();
|
||||
$options->to = $recipient_number;
|
||||
$options->charset = 'utf8';
|
||||
$content_full = $message->getContent();
|
||||
|
||||
// Determine when to send this message.
|
||||
if ($datetime = $message->getDelay())
|
||||
{
|
||||
if ($datetime > time())
|
||||
{
|
||||
$options->datetime = gmdate('YmdHis', $datetime + (3600 * 9));
|
||||
}
|
||||
}
|
||||
|
||||
// Determine the message type based on the length.
|
||||
$content_full = $message->getContent();
|
||||
$detected_type = $message->checkLength($content_full, $this->_maxlength_sms) ? 'SMS' : 'LMS';
|
||||
$options->type = $detected_type;
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ class SMS
|
|||
protected $subject = '';
|
||||
protected $content = '';
|
||||
protected $attachments = array();
|
||||
protected $delay_timestamp = 0;
|
||||
protected $force_sms = false;
|
||||
protected $allow_split_sms = true;
|
||||
protected $allow_split_lms = true;
|
||||
|
|
@ -313,6 +314,43 @@ class SMS
|
|||
return $this->attachments;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delay sending the message.
|
||||
*
|
||||
* Delays (in seconds) less than 1 year will be treated as relative to the
|
||||
* current time. Greater values will be interpreted as a Unix timestamp.
|
||||
*
|
||||
* This feature may not be implemented by all drivers.
|
||||
*
|
||||
* @param int $when Unix timestamp
|
||||
* @return bool
|
||||
*/
|
||||
public function setDelay($when)
|
||||
{
|
||||
if ($when <= (86400 * 365))
|
||||
{
|
||||
$when = time() + $when;
|
||||
}
|
||||
|
||||
$this->delay_timestamp = intval($when);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Unix timestamp of when to send the message.
|
||||
*
|
||||
* This method always returns a Unix timestamp, even if the original value
|
||||
* was given as a relative delay.
|
||||
*
|
||||
* This feature may not be implemented by all drivers.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getDelay()
|
||||
{
|
||||
return $this->delay_timestamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Force this message to use SMS (not LMS or MMS).
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue