@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add infrastructure for sending SMS via AWS SNS

Summary:
Ref T920. Ref T13235. This adds a `Future`, similar to `TwilioFuture`, for interacting with Amazon's SNS service.

Also updates the documentation.

Also makes the code consistent with the documentation by accepting a `media` argument.

Test Plan: Clicked the "send test message" button from the Settings UI.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Maniphest Tasks: T13235, T920

Differential Revision: https://secure.phabricator.com/D19982

+119
+4
src/__phutil_library_map__.php
··· 2083 2083 'PhabricatorAjaxRequestExceptionHandler' => 'aphront/handler/PhabricatorAjaxRequestExceptionHandler.php', 2084 2084 'PhabricatorAlmanacApplication' => 'applications/almanac/application/PhabricatorAlmanacApplication.php', 2085 2085 'PhabricatorAmazonAuthProvider' => 'applications/auth/provider/PhabricatorAmazonAuthProvider.php', 2086 + 'PhabricatorAmazonSNSFuture' => 'applications/metamta/future/PhabricatorAmazonSNSFuture.php', 2086 2087 'PhabricatorAnchorView' => 'view/layout/PhabricatorAnchorView.php', 2087 2088 'PhabricatorAphlictManagementDebugWorkflow' => 'applications/aphlict/management/PhabricatorAphlictManagementDebugWorkflow.php', 2088 2089 'PhabricatorAphlictManagementNotifyWorkflow' => 'applications/aphlict/management/PhabricatorAphlictManagementNotifyWorkflow.php', ··· 3425 3426 'PhabricatorMacroViewController' => 'applications/macro/controller/PhabricatorMacroViewController.php', 3426 3427 'PhabricatorMailAdapter' => 'applications/metamta/adapter/PhabricatorMailAdapter.php', 3427 3428 'PhabricatorMailAmazonSESAdapter' => 'applications/metamta/adapter/PhabricatorMailAmazonSESAdapter.php', 3429 + 'PhabricatorMailAmazonSNSAdapter' => 'applications/metamta/adapter/PhabricatorMailAmazonSNSAdapter.php', 3428 3430 'PhabricatorMailAttachment' => 'applications/metamta/message/PhabricatorMailAttachment.php', 3429 3431 'PhabricatorMailConfigTestCase' => 'applications/metamta/storage/__tests__/PhabricatorMailConfigTestCase.php', 3430 3432 'PhabricatorMailEmailEngine' => 'applications/metamta/engine/PhabricatorMailEmailEngine.php', ··· 7773 7775 'PhabricatorAjaxRequestExceptionHandler' => 'PhabricatorRequestExceptionHandler', 7774 7776 'PhabricatorAlmanacApplication' => 'PhabricatorApplication', 7775 7777 'PhabricatorAmazonAuthProvider' => 'PhabricatorOAuth2AuthProvider', 7778 + 'PhabricatorAmazonSNSFuture' => 'PhutilAWSFuture', 7776 7779 'PhabricatorAnchorView' => 'AphrontView', 7777 7780 'PhabricatorAphlictManagementDebugWorkflow' => 'PhabricatorAphlictManagementWorkflow', 7778 7781 'PhabricatorAphlictManagementNotifyWorkflow' => 'PhabricatorAphlictManagementWorkflow', ··· 9318 9321 'PhabricatorMacroViewController' => 'PhabricatorMacroController', 9319 9322 'PhabricatorMailAdapter' => 'Phobject', 9320 9323 'PhabricatorMailAmazonSESAdapter' => 'PhabricatorMailAdapter', 9324 + 'PhabricatorMailAmazonSNSAdapter' => 'PhabricatorMailAdapter', 9321 9325 'PhabricatorMailAttachment' => 'Phobject', 9322 9326 'PhabricatorMailConfigTestCase' => 'PhabricatorTestCase', 9323 9327 'PhabricatorMailEmailEngine' => 'PhabricatorMailMessageEngine',
+63
src/applications/metamta/adapter/PhabricatorMailAmazonSNSAdapter.php
··· 1 + <?php 2 + 3 + final class PhabricatorMailAmazonSNSAdapter 4 + extends PhabricatorMailAdapter { 5 + 6 + const ADAPTERTYPE = 'sns'; 7 + 8 + public function getSupportedMessageTypes() { 9 + return array( 10 + PhabricatorMailSMSMessage::MESSAGETYPE, 11 + ); 12 + } 13 + 14 + protected function validateOptions(array $options) { 15 + PhutilTypeSpec::checkMap( 16 + $options, 17 + array( 18 + 'access-key' => 'string', 19 + 'secret-key' => 'string', 20 + 'endpoint' => 'string', 21 + 'region' => 'string', 22 + )); 23 + } 24 + 25 + public function newDefaultOptions() { 26 + return array( 27 + 'access-key' => null, 28 + 'secret-key' => null, 29 + 'endpoint' => null, 30 + 'region' => null, 31 + ); 32 + } 33 + 34 + public function sendMessage(PhabricatorMailExternalMessage $message) { 35 + $access_key = $this->getOption('access-key'); 36 + 37 + $secret_key = $this->getOption('secret-key'); 38 + $secret_key = new PhutilOpaqueEnvelope($secret_key); 39 + 40 + $endpoint = $this->getOption('endpoint'); 41 + $region = $this->getOption('region'); 42 + 43 + $to_number = $message->getToNumber(); 44 + $text_body = $message->getTextBody(); 45 + 46 + $params = array( 47 + 'Version' => '2010-03-31', 48 + 'Action' => 'Publish', 49 + 'PhoneNumber' => $to_number->toE164(), 50 + 'Message' => $text_body, 51 + ); 52 + 53 + return id(new PhabricatorAmazonSNSFuture()) 54 + ->setParameters($params) 55 + ->setEndpoint($endpoint) 56 + ->setAccessKey($access_key) 57 + ->setSecretKey($secret_key) 58 + ->setRegion($region) 59 + ->setTimeout(60) 60 + ->resolve(); 61 + } 62 + 63 + }
+41
src/applications/metamta/future/PhabricatorAmazonSNSFuture.php
··· 1 + <?php 2 + 3 + final class PhabricatorAmazonSNSFuture extends PhutilAWSFuture { 4 + private $parameters = array(); 5 + private $timeout; 6 + 7 + public function setParameters($parameters) { 8 + $this->parameters = $parameters; 9 + return $this; 10 + } 11 + 12 + protected function getParameters() { 13 + return $this->parameters; 14 + } 15 + 16 + public function getServiceName() { 17 + return 'sns'; 18 + } 19 + 20 + public function setTimeout($timeout) { 21 + $this->timeout = $timeout; 22 + return $this; 23 + } 24 + 25 + public function getTimeout() { 26 + return $this->timeout; 27 + } 28 + 29 + protected function getProxiedFuture() { 30 + $future = parent::getProxiedFuture(); 31 + 32 + $timeout = $this->getTimeout(); 33 + if ($timeout) { 34 + $future->setTimeout($timeout); 35 + } 36 + 37 + return $future; 38 + 39 + } 40 + 41 + }
+10
src/docs/user/configuration/configuring_outbound_email.diviner
··· 97 97 - `ses`: Use Amazon SES. 98 98 - `sendgrid`: Use SendGrid. 99 99 - `postmark`: Use Postmark. 100 + - `sns`: Use Amazon SNS (only for sending SMS messages). 100 101 101 102 It also supports these local mailers: 102 103 ··· 208 209 config, then follow the Amazon SES verification process to verify it. You 209 210 won't be able to send email until you do this! 210 211 212 + Mailer: Amazon SNS 213 + ================== 214 + 215 + Amazon SNS is Amazon's cloud notification service. You can learn more at 216 + <http://aws.amazon.com/sns/>. Note that this mailer is only able to send 217 + SMS messages, not emails. 218 + 219 + To use this mailer, set `type` to `sns`, then configure the options similarly 220 + to the SES configuration above. 211 221 212 222 Mailer: SendGrid 213 223 ================
+1
src/infrastructure/cluster/config/PhabricatorClusterMailersConfigType.php
··· 45 45 'options' => 'optional wild', 46 46 'inbound' => 'optional bool', 47 47 'outbound' => 'optional bool', 48 + 'media' => 'optional list<string>', 48 49 )); 49 50 } catch (Exception $ex) { 50 51 throw $this->newException(