Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15443321
D19982.id47684.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
8 KB
Referenced Files
None
Subscribers
None
D19982.id47684.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
@@ -2073,6 +2073,7 @@
'PeopleUserLogGarbageCollector' => 'applications/people/garbagecollector/PeopleUserLogGarbageCollector.php',
'Phabricator404Controller' => 'applications/base/controller/Phabricator404Controller.php',
'PhabricatorAWSConfigOptions' => 'applications/config/option/PhabricatorAWSConfigOptions.php',
+ 'PhabricatorAWSSimpleMessagingServiceFuture' => 'applications/notification/future/PhabricatorAWSSimpleMessagingServiceFuture.php',
'PhabricatorAccessControlTestCase' => 'applications/base/controller/__tests__/PhabricatorAccessControlTestCase.php',
'PhabricatorAccessLog' => 'infrastructure/log/PhabricatorAccessLog.php',
'PhabricatorAccessLogConfigOptions' => 'applications/config/option/PhabricatorAccessLogConfigOptions.php',
@@ -3508,6 +3509,8 @@
'PhabricatorNotificationDestructionEngineExtension' => 'applications/notification/engineextension/PhabricatorNotificationDestructionEngineExtension.php',
'PhabricatorNotificationIndividualController' => 'applications/notification/controller/PhabricatorNotificationIndividualController.php',
'PhabricatorNotificationListController' => 'applications/notification/controller/PhabricatorNotificationListController.php',
+ 'PhabricatorNotificationManagementSMSWorkflow' => 'applications/notification/management/PhabricatorNotificationManagementSMSWorkflow.php',
+ 'PhabricatorNotificationManagementWorkflow' => 'applications/notification/management/PhabricatorNotificationManagementWorkflow.php',
'PhabricatorNotificationPanelController' => 'applications/notification/controller/PhabricatorNotificationPanelController.php',
'PhabricatorNotificationQuery' => 'applications/notification/query/PhabricatorNotificationQuery.php',
'PhabricatorNotificationSearchEngine' => 'applications/notification/query/PhabricatorNotificationSearchEngine.php',
@@ -7695,6 +7698,7 @@
'PeopleUserLogGarbageCollector' => 'PhabricatorGarbageCollector',
'Phabricator404Controller' => 'PhabricatorController',
'PhabricatorAWSConfigOptions' => 'PhabricatorApplicationConfigOptions',
+ 'PhabricatorAWSSimpleMessagingServiceFuture' => 'PhutilAWSFuture',
'PhabricatorAccessControlTestCase' => 'PhabricatorTestCase',
'PhabricatorAccessLog' => 'Phobject',
'PhabricatorAccessLogConfigOptions' => 'PhabricatorApplicationConfigOptions',
@@ -9333,6 +9337,8 @@
'PhabricatorNotificationDestructionEngineExtension' => 'PhabricatorDestructionEngineExtension',
'PhabricatorNotificationIndividualController' => 'PhabricatorNotificationController',
'PhabricatorNotificationListController' => 'PhabricatorNotificationController',
+ 'PhabricatorNotificationManagementSMSWorkflow' => 'PhabricatorNotificationManagementWorkflow',
+ 'PhabricatorNotificationManagementWorkflow' => 'PhabricatorManagementWorkflow',
'PhabricatorNotificationPanelController' => 'PhabricatorNotificationController',
'PhabricatorNotificationQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'PhabricatorNotificationSearchEngine' => 'PhabricatorApplicationSearchEngine',
diff --git a/src/applications/config/option/PhabricatorAWSConfigOptions.php b/src/applications/config/option/PhabricatorAWSConfigOptions.php
--- a/src/applications/config/option/PhabricatorAWSConfigOptions.php
+++ b/src/applications/config/option/PhabricatorAWSConfigOptions.php
@@ -54,6 +54,19 @@
$this->newOption('amazon-ec2.secret-key', 'string', null)
->setHidden(true)
->setDescription(pht('Secret key for Amazon EC2.')),
+ $this->newOption('amazon-sns.access-key', 'string', null)
+ ->setLocked(true)
+ ->setDescription(pht('Access key for Amazon SNS.')),
+ $this->newOption('amazon-sns.secret-key', 'string', null)
+ ->setHidden(true)
+ ->setDescription(pht('Secret key for Amazon SNS.')),
+ $this->newOption('amazon-sns.region', 'string', null)
+ ->setLocked(true)
+ ->setDescription(
+ pht(
+ 'Amazon SNS region to direct your requests to. You can find a '.
+ 'list of available regions in the AWS documentation.'))
+ ->addExample('us-east-1', pht('US East Region')),
);
}
diff --git a/src/applications/notification/future/PhabricatorAWSSimpleMessagingServiceFuture.php b/src/applications/notification/future/PhabricatorAWSSimpleMessagingServiceFuture.php
new file mode 100644
--- /dev/null
+++ b/src/applications/notification/future/PhabricatorAWSSimpleMessagingServiceFuture.php
@@ -0,0 +1,19 @@
+<?php
+
+final class PhabricatorAWSSimpleMessagingServiceFuture extends PhutilAWSFuture {
+ private $parameters = array();
+
+ public function setParameters($parameters) {
+ $this->parameters = $parameters;
+ return $this;
+ }
+
+ protected function getParameters() {
+ return $this->parameters;
+ }
+
+ public function getServiceName() {
+ return 'sns';
+ }
+
+}
diff --git a/src/applications/notification/management/PhabricatorNotificationManagementSMSWorkflow.php b/src/applications/notification/management/PhabricatorNotificationManagementSMSWorkflow.php
new file mode 100644
--- /dev/null
+++ b/src/applications/notification/management/PhabricatorNotificationManagementSMSWorkflow.php
@@ -0,0 +1,72 @@
+<?php
+
+final class PhabricatorNotificationManagementSMSWorkflow
+ extends PhabricatorNotificationManagementWorkflow {
+
+ protected function didConstruct() {
+ $this
+ ->setName('send')
+ ->setExamples('**send** __phone_number__')
+ ->setSynopsis(
+ pht(
+ 'Send an SMS.'))
+ ->setArguments(
+ array(
+ array(
+ 'name' => 'argv',
+ 'wildcard' => true,
+ ),
+ array(
+ 'name' => 'message',
+ 'param' => 'message',
+ 'help' => 'Override the default message body.',
+ ),
+ ));
+ }
+
+ public function execute(PhutilArgumentParser $args) {
+ $argv = $args->getArg('argv');
+
+ if (!$argv) {
+ throw new PhutilArgumentUsageException(
+ pht('You must specify a phone number.'));
+ }
+
+ $phone = head($argv);
+ $message = $args->getArg('message');
+ if (!$message) {
+ $message = 'Greetings from Phabricator!';
+ }
+
+ $params = array(
+ 'Action' => 'Publish',
+ 'PhoneNumber' => $phone,
+ 'Message' => $message,
+ );
+
+ $result = $this->resolveSNSMethod($params);
+ $console = PhutilConsole::getConsole();
+ $console->writeOut("%s\n", pht('SMS sent.'));
+ return 0;
+ }
+
+ protected function resolveSNSMethod(array $params) {
+ $params = $params + array(
+ 'Version' => '2010-03-31',
+ );
+
+ $access_key = PhabricatorEnv::getEnvConfig('amazon-sns.access-key');
+ $secret_key = PhabricatorEnv::getEnvConfig('amazon-sns.secret-key');
+ $secret_key = new PhutilOpaqueEnvelope($secret_key);
+ $region = PhabricatorEnv::getEnvConfig('amazon-sns.region');
+
+ return id(new PhabricatorAWSSimpleMessagingServiceFuture())
+ ->setParameters($params)
+ ->setEndpoint('sns.us-east-1.amazonaws.com')
+ ->setAccessKey($access_key)
+ ->setSecretKey($secret_key)
+ ->setRegion($region)
+ ->resolve();
+ }
+
+}
diff --git a/src/applications/notification/management/PhabricatorNotificationManagementWorkflow.php b/src/applications/notification/management/PhabricatorNotificationManagementWorkflow.php
new file mode 100644
--- /dev/null
+++ b/src/applications/notification/management/PhabricatorNotificationManagementWorkflow.php
@@ -0,0 +1,4 @@
+<?php
+
+abstract class PhabricatorNotificationManagementWorkflow
+ extends PhabricatorManagementWorkflow {}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Mar 28, 3:41 AM (1 w, 19 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7725089
Default Alt Text
D19982.id47684.diff (8 KB)
Attached To
Mode
D19982: Add infrastructure for sending SMS via AWS SNS
Attached
Detach File
Event Timeline
Log In to Comment