Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F97212250
PhabricatorSMS.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Fri, Jan 3, 12:10
Size
2 KB
Mime Type
text/x-php
Expires
Sun, Jan 5, 12:10 (2 d)
Engine
blob
Format
Raw Data
Handle
23355741
Attached To
rPH Phabricator
PhabricatorSMS.php
View Options
<?php
final
class
PhabricatorSMS
extends
PhabricatorSMSDAO
{
const
MAXIMUM_SEND_TRIES
=
5
;
/**
* Status constants should be 16 characters or less. See status entries
* for details on what they indicate about the underlying SMS.
*/
// in the beginning, all SMS are unsent
const
STATUS_UNSENT
=
'unsent'
;
// that nebulous time when we've sent it from Phabricator but haven't
// heard anything from the external API
const
STATUS_SENT_UNCONFIRMED
=
'sent-unconfirmed'
;
// "success"
const
STATUS_SENT
=
'sent'
;
// "fail" but we'll try again
const
STATUS_FAILED
=
'failed'
;
// we're giving up on our external API partner
const
STATUS_FAILED_PERMANENTLY
=
'permafailed'
;
const
SHORTNAME_PLACEHOLDER
=
'phabricator'
;
protected
$providerShortName
;
protected
$providerSMSID
;
// numbers can be up to 20 digits long
protected
$toNumber
;
protected
$fromNumber
;
protected
$body
;
protected
$sendStatus
;
public
static
function
initializeNewSMS
(
$body
)
{
// NOTE: these values will be updated to correct values when the
// SMS is sent for the first time. In particular, the ProviderShortName
// and ProviderSMSID are totally garbage data before a send it attempted.
return
id
(
new
PhabricatorSMS
())
->
setBody
(
$body
)
->
setSendStatus
(
PhabricatorSMS
::
STATUS_UNSENT
)
->
setProviderShortName
(
PhabricatorSMS
::
SHORTNAME_PLACEHOLDER
)
->
setProviderSMSID
(
Filesystem
::
readRandomCharacters
(
40
));
}
protected
function
getConfiguration
()
{
return
array
(
self
::
CONFIG_COLUMN_SCHEMA
=>
array
(
'providerShortName'
=>
'text16'
,
'providerSMSID'
=>
'text40'
,
'toNumber'
=>
'text20'
,
'fromNumber'
=>
'text20?'
,
'body'
=>
'text'
,
'sendStatus'
=>
'text16?'
,
),
self
::
CONFIG_KEY_SCHEMA
=>
array
(
'key_provider'
=>
array
(
'columns'
=>
array
(
'providerSMSID'
,
'providerShortName'
),
'unique'
=>
true
,
),
),
)
+
parent
::
getConfiguration
();
}
public
function
getTableName
()
{
// Slightly non-standard, but otherwise this class needs "MetaMTA" in its
// name. :/
return
'sms'
;
}
public
function
hasBeenSentAtLeastOnce
()
{
return
(
$this
->
getProviderShortName
()
!=
PhabricatorSMS
::
SHORTNAME_PLACEHOLDER
);
}
}
Event Timeline
Log In to Comment