Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15282869
D19982.id47824.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
11 KB
Referenced Files
None
Subscribers
None
D19982.id47824.diff
View Options
diff --git a/scripts/sms/manage_sms.php b/scripts/sms/manage_sms.php
new file mode 100755
--- /dev/null
+++ b/scripts/sms/manage_sms.php
@@ -0,0 +1,21 @@
+#!/usr/bin/env php
+<?php
+
+$root = dirname(dirname(dirname(__FILE__)));
+require_once $root.'/scripts/init/init-script.php';
+
+$args = new PhutilArgumentParser($argv);
+$args->setTagline(pht('manage sms'));
+$args->setSynopsis(<<<EOSYNOPSIS
+**herald** __command__ [__options__]
+ Manage and debug SMS.
+
+EOSYNOPSIS
+ );
+$args->parseStandardArguments();
+
+$workflows = id(new PhutilClassMapQuery())
+ ->setAncestorClass('PhabricatorNotificationManagementWorkflow')
+ ->execute();
+$workflows[] = new PhutilHelpArgumentWorkflow();
+$args->parseWorkflows($workflows);
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -2071,7 +2071,6 @@
'PeopleMainMenuBarExtension' => 'applications/people/engineextension/PeopleMainMenuBarExtension.php',
'PeopleUserLogGarbageCollector' => 'applications/people/garbagecollector/PeopleUserLogGarbageCollector.php',
'Phabricator404Controller' => 'applications/base/controller/Phabricator404Controller.php',
- 'PhabricatorAWSConfigOptions' => 'applications/config/option/PhabricatorAWSConfigOptions.php',
'PhabricatorAccessControlTestCase' => 'applications/base/controller/__tests__/PhabricatorAccessControlTestCase.php',
'PhabricatorAccessLog' => 'infrastructure/log/PhabricatorAccessLog.php',
'PhabricatorAccessLogConfigOptions' => 'applications/config/option/PhabricatorAccessLogConfigOptions.php',
@@ -2083,6 +2082,7 @@
'PhabricatorAjaxRequestExceptionHandler' => 'aphront/handler/PhabricatorAjaxRequestExceptionHandler.php',
'PhabricatorAlmanacApplication' => 'applications/almanac/application/PhabricatorAlmanacApplication.php',
'PhabricatorAmazonAuthProvider' => 'applications/auth/provider/PhabricatorAmazonAuthProvider.php',
+ 'PhabricatorAmazonSNSFuture' => 'applications/metamta/future/PhabricatorAmazonSNSFuture.php',
'PhabricatorAnchorView' => 'view/layout/PhabricatorAnchorView.php',
'PhabricatorAphlictManagementDebugWorkflow' => 'applications/aphlict/management/PhabricatorAphlictManagementDebugWorkflow.php',
'PhabricatorAphlictManagementNotifyWorkflow' => 'applications/aphlict/management/PhabricatorAphlictManagementNotifyWorkflow.php',
@@ -3425,6 +3425,7 @@
'PhabricatorMacroViewController' => 'applications/macro/controller/PhabricatorMacroViewController.php',
'PhabricatorMailAdapter' => 'applications/metamta/adapter/PhabricatorMailAdapter.php',
'PhabricatorMailAmazonSESAdapter' => 'applications/metamta/adapter/PhabricatorMailAmazonSESAdapter.php',
+ 'PhabricatorMailAmazonSNSAdapter' => 'applications/metamta/adapter/PhabricatorMailAmazonSNSAdapter.php',
'PhabricatorMailAttachment' => 'applications/metamta/message/PhabricatorMailAttachment.php',
'PhabricatorMailConfigTestCase' => 'applications/metamta/storage/__tests__/PhabricatorMailConfigTestCase.php',
'PhabricatorMailEmailEngine' => 'applications/metamta/engine/PhabricatorMailEmailEngine.php',
@@ -7761,7 +7762,6 @@
'PeopleMainMenuBarExtension' => 'PhabricatorMainMenuBarExtension',
'PeopleUserLogGarbageCollector' => 'PhabricatorGarbageCollector',
'Phabricator404Controller' => 'PhabricatorController',
- 'PhabricatorAWSConfigOptions' => 'PhabricatorApplicationConfigOptions',
'PhabricatorAccessControlTestCase' => 'PhabricatorTestCase',
'PhabricatorAccessLog' => 'Phobject',
'PhabricatorAccessLogConfigOptions' => 'PhabricatorApplicationConfigOptions',
@@ -7773,6 +7773,7 @@
'PhabricatorAjaxRequestExceptionHandler' => 'PhabricatorRequestExceptionHandler',
'PhabricatorAlmanacApplication' => 'PhabricatorApplication',
'PhabricatorAmazonAuthProvider' => 'PhabricatorOAuth2AuthProvider',
+ 'PhabricatorAmazonSNSFuture' => 'PhutilAWSFuture',
'PhabricatorAnchorView' => 'AphrontView',
'PhabricatorAphlictManagementDebugWorkflow' => 'PhabricatorAphlictManagementWorkflow',
'PhabricatorAphlictManagementNotifyWorkflow' => 'PhabricatorAphlictManagementWorkflow',
@@ -9318,6 +9319,7 @@
'PhabricatorMacroViewController' => 'PhabricatorMacroController',
'PhabricatorMailAdapter' => 'Phobject',
'PhabricatorMailAmazonSESAdapter' => 'PhabricatorMailAdapter',
+ 'PhabricatorMailAmazonSNSAdapter' => 'PhabricatorMailAdapter',
'PhabricatorMailAttachment' => 'Phobject',
'PhabricatorMailConfigTestCase' => 'PhabricatorTestCase',
'PhabricatorMailEmailEngine' => 'PhabricatorMailMessageEngine',
diff --git a/src/applications/config/option/PhabricatorAWSConfigOptions.php b/src/applications/config/option/PhabricatorAWSConfigOptions.php
deleted file mode 100644
--- a/src/applications/config/option/PhabricatorAWSConfigOptions.php
+++ /dev/null
@@ -1,60 +0,0 @@
-<?php
-
-final class PhabricatorAWSConfigOptions
- extends PhabricatorApplicationConfigOptions {
-
- public function getName() {
- return pht('Amazon Web Services');
- }
-
- public function getDescription() {
- return pht('Configure integration with AWS (EC2, SES, S3, etc).');
- }
-
- public function getIcon() {
- return 'fa-server';
- }
-
- public function getGroup() {
- return 'core';
- }
-
- public function getOptions() {
- return array(
- $this->newOption('amazon-s3.access-key', 'string', null)
- ->setLocked(true)
- ->setDescription(pht('Access key for Amazon S3.')),
- $this->newOption('amazon-s3.secret-key', 'string', null)
- ->setHidden(true)
- ->setDescription(pht('Secret key for Amazon S3.')),
- $this->newOption('amazon-s3.region', 'string', null)
- ->setLocked(true)
- ->setDescription(
- pht(
- 'Amazon S3 region where your S3 bucket is located. When you '.
- 'specify a region, you should also specify a corresponding '.
- 'endpoint with `amazon-s3.endpoint`. You can find a list of '.
- 'available regions and endpoints in the AWS documentation.'))
- ->addExample('us-west-1', pht('USWest Region')),
- $this->newOption('amazon-s3.endpoint', 'string', null)
- ->setLocked(true)
- ->setDescription(
- pht(
- 'Explicit S3 endpoint to use. This should be the endpoint '.
- 'which corresponds to the region you have selected in '.
- '`amazon-s3.region`. Phabricator can not determine the correct '.
- 'endpoint automatically because some endpoint locations are '.
- 'irregular.'))
- ->addExample(
- 's3-us-west-1.amazonaws.com',
- pht('Use specific endpoint')),
- $this->newOption('amazon-ec2.access-key', 'string', null)
- ->setLocked(true)
- ->setDescription(pht('Access key for Amazon EC2.')),
- $this->newOption('amazon-ec2.secret-key', 'string', null)
- ->setHidden(true)
- ->setDescription(pht('Secret key for Amazon EC2.')),
- );
- }
-
-}
diff --git a/src/applications/metamta/adapter/PhabricatorMailAmazonSNSAdapter.php b/src/applications/metamta/adapter/PhabricatorMailAmazonSNSAdapter.php
new file mode 100644
--- /dev/null
+++ b/src/applications/metamta/adapter/PhabricatorMailAmazonSNSAdapter.php
@@ -0,0 +1,66 @@
+<?php
+
+final class PhabricatorMailAmazonSNSAdapter
+ extends PhabricatorMailAdapter {
+
+ const ADAPTERTYPE = 'sns';
+
+ public function getSupportedMessageTypes() {
+ return array(
+ PhabricatorMailSMSMessage::MESSAGETYPE,
+ );
+ }
+
+ protected function validateOptions(array $options) {
+ PhutilTypeSpec::checkMap(
+ $options,
+ array(
+ 'access-key' => 'string',
+ 'secret-key' => 'string',
+ 'endpoint' => 'string',
+ 'region' => 'string',
+ ));
+ }
+
+ public function newDefaultOptions() {
+ return array(
+ 'access-key' => null,
+ 'secret-key' => null,
+ 'endpoint' => null,
+ 'region' => null,
+ );
+ }
+
+
+ public function sendMessage(PhabricatorMailExternalMessage $message) {
+ $access_key = $this->getOption('access-key');
+
+ $secret_key = $this->getOption('secret-key');
+ $secret_key = new PhutilOpaqueEnvelope($secret_key);
+
+ $endpoint = $this->getOption('endpoint');
+ $region = $this->getOption('region');
+
+ $to_number = $message->getToNumber();
+ $text_body = $message->getTextBody();
+
+
+ $params = array(
+ 'Version' => '2010-03-31',
+ 'Action' => 'Publish',
+ 'PhoneNumber' => $to_number->toE164(),
+ 'Message' => $text_body,
+ );
+
+
+ return id(new PhabricatorAmazonSNSFuture())
+ ->setParameters($params)
+ ->setEndpoint($endpoint)
+ ->setAccessKey($access_key)
+ ->setSecretKey($secret_key)
+ ->setRegion($region)
+ ->setTimeout(60)
+ ->resolve();
+ }
+
+}
diff --git a/src/applications/metamta/future/PhabricatorAmazonSNSFuture.php b/src/applications/metamta/future/PhabricatorAmazonSNSFuture.php
new file mode 100644
--- /dev/null
+++ b/src/applications/metamta/future/PhabricatorAmazonSNSFuture.php
@@ -0,0 +1,41 @@
+<?php
+
+final class PhabricatorAmazonSNSFuture extends PhutilAWSFuture {
+ private $parameters = array();
+ private $timeout;
+
+ public function setParameters($parameters) {
+ $this->parameters = $parameters;
+ return $this;
+ }
+
+ protected function getParameters() {
+ return $this->parameters;
+ }
+
+ public function getServiceName() {
+ return 'sns';
+ }
+
+ public function setTimeout($timeout) {
+ $this->timeout = $timeout;
+ return $this;
+ }
+
+ public function getTimeout() {
+ return $this->timeout;
+ }
+
+ protected function getProxiedFuture() {
+ $future = parent::getProxiedFuture();
+
+ $timeout = $this->getTimeout();
+ if ($timeout) {
+ $future->setTimeout($timeout);
+ }
+
+ return $future;
+
+ }
+
+}
diff --git a/src/docs/user/configuration/configuring_outbound_email.diviner b/src/docs/user/configuration/configuring_outbound_email.diviner
--- a/src/docs/user/configuration/configuring_outbound_email.diviner
+++ b/src/docs/user/configuration/configuring_outbound_email.diviner
@@ -97,6 +97,7 @@
- `ses`: Use Amazon SES.
- `sendgrid`: Use SendGrid.
- `postmark`: Use Postmark.
+ - `sns`: Use Amazon SNS (only for sending SMS messages).
It also supports these local mailers:
@@ -208,6 +209,15 @@
config, then follow the Amazon SES verification process to verify it. You
won't be able to send email until you do this!
+Mailer: Amazon SNS
+==================
+
+Amazon SNS is Amazon's cloud notification service. You can learn more at
+<http://aws.amazon.com/ses/>. Note that this mailer is only able to send
+SMS messages, not emails.
+
+To use this mailer, set `type` to `sns`, then configure the options similarly
+to the SNS configuration above.
Mailer: SendGrid
================
diff --git a/src/infrastructure/cluster/config/PhabricatorClusterMailersConfigType.php b/src/infrastructure/cluster/config/PhabricatorClusterMailersConfigType.php
--- a/src/infrastructure/cluster/config/PhabricatorClusterMailersConfigType.php
+++ b/src/infrastructure/cluster/config/PhabricatorClusterMailersConfigType.php
@@ -45,6 +45,7 @@
'options' => 'optional wild',
'inbound' => 'optional bool',
'outbound' => 'optional bool',
+ 'media' => 'optional list<string>',
));
} catch (Exception $ex) {
throw $this->newException(
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Mar 5, 3:15 AM (2 w, 4 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7223433
Default Alt Text
D19982.id47824.diff (11 KB)
Attached To
Mode
D19982: Add infrastructure for sending SMS via AWS SNS
Attached
Detach File
Event Timeline
Log In to Comment