Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F102088021
PhabricatorMailTwilioAdapter.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
Sun, Feb 16, 23:57
Size
1 KB
Mime Type
text/x-php
Expires
Tue, Feb 18, 23:57 (2 d)
Engine
blob
Format
Raw Data
Handle
24279051
Attached To
rPH Phabricator
PhabricatorMailTwilioAdapter.php
View Options
<?php
final
class
PhabricatorMailTwilioAdapter
extends
PhabricatorMailAdapter
{
const
ADAPTERTYPE
=
'twilio'
;
public
function
getSupportedMessageTypes
()
{
return
array
(
PhabricatorMailSMSMessage
::
MESSAGETYPE
,
);
}
protected
function
validateOptions
(
array
$options
)
{
PhutilTypeSpec
::
checkMap
(
$options
,
array
(
'account-sid'
=>
'string'
,
'auth-token'
=>
'string'
,
'from-number'
=>
'string'
,
));
// Construct an object from the "from-number" to validate it.
$number
=
new
PhabricatorPhoneNumber
(
$options
[
'from-number'
]);
}
public
function
newDefaultOptions
()
{
return
array
(
'account-sid'
=>
null
,
'auth-token'
=>
null
,
'from-number'
=>
null
,
);
}
public
function
sendMessage
(
PhabricatorMailExternalMessage
$message
)
{
$account_sid
=
$this
->
getOption
(
'account-sid'
);
$auth_token
=
$this
->
getOption
(
'auth-token'
);
$auth_token
=
new
PhutilOpaqueEnvelope
(
$auth_token
);
$from_number
=
$this
->
getOption
(
'from-number'
);
$from_number
=
new
PhabricatorPhoneNumber
(
$from_number
);
$to_number
=
$message
->
getToNumber
();
$text_body
=
$message
->
getTextBody
();
$parameters
=
array
(
'From'
=>
$from_number
->
toE164
(),
'To'
=>
$to_number
->
toE164
(),
'Body'
=>
$text_body
,
);
$result
=
id
(
new
PhabricatorTwilioFuture
())
->
setAccountSID
(
$account_sid
)
->
setAuthToken
(
$auth_token
)
->
setMethod
(
'Messages.json'
,
$parameters
)
->
setTimeout
(
60
)
->
resolve
();
}
}
Event Timeline
Log In to Comment