Page MenuHomePhabricator

D19939.diff
No OneTemporary

D19939.diff

diff --git a/resources/sql/autopatches/20190101.sms.01.drop.sql b/resources/sql/autopatches/20190101.sms.01.drop.sql
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20190101.sms.01.drop.sql
@@ -0,0 +1 @@
+DROP TABLE {$NAMESPACE}_metamta.sms;
diff --git a/scripts/sms/manage_sms.php b/scripts/sms/manage_sms.php
deleted file mode 100755
--- a/scripts/sms/manage_sms.php
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/usr/bin/env php
-<?php
-
-$root = dirname(dirname(dirname(__FILE__)));
-require_once $root.'/scripts/__init_script__.php';
-
-$args = new PhutilArgumentParser($argv);
-$args->setTagline(pht('manage SMS'));
-$args->setSynopsis(<<<EOSYNOPSIS
-**sms** __command__ [__options__]
- Manage Phabricator SMS stuff.
-
-EOSYNOPSIS
- );
-$args->parseStandardArguments();
-
-$workflows = id(new PhutilClassMapQuery())
- ->setAncestorClass('PhabricatorSMSManagementWorkflow')
- ->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
@@ -4239,19 +4239,6 @@
'PhabricatorResourceSite' => 'aphront/site/PhabricatorResourceSite.php',
'PhabricatorRobotsController' => 'applications/system/controller/PhabricatorRobotsController.php',
'PhabricatorS3FileStorageEngine' => 'applications/files/engine/PhabricatorS3FileStorageEngine.php',
- 'PhabricatorSMS' => 'infrastructure/sms/storage/PhabricatorSMS.php',
- 'PhabricatorSMSConfigOptions' => 'applications/config/option/PhabricatorSMSConfigOptions.php',
- 'PhabricatorSMSDAO' => 'infrastructure/sms/storage/PhabricatorSMSDAO.php',
- 'PhabricatorSMSDemultiplexWorker' => 'infrastructure/sms/worker/PhabricatorSMSDemultiplexWorker.php',
- 'PhabricatorSMSImplementationAdapter' => 'infrastructure/sms/adapter/PhabricatorSMSImplementationAdapter.php',
- 'PhabricatorSMSImplementationTestBlackholeAdapter' => 'infrastructure/sms/adapter/PhabricatorSMSImplementationTestBlackholeAdapter.php',
- 'PhabricatorSMSImplementationTwilioAdapter' => 'infrastructure/sms/adapter/PhabricatorSMSImplementationTwilioAdapter.php',
- 'PhabricatorSMSManagementListOutboundWorkflow' => 'infrastructure/sms/management/PhabricatorSMSManagementListOutboundWorkflow.php',
- 'PhabricatorSMSManagementSendTestWorkflow' => 'infrastructure/sms/management/PhabricatorSMSManagementSendTestWorkflow.php',
- 'PhabricatorSMSManagementShowOutboundWorkflow' => 'infrastructure/sms/management/PhabricatorSMSManagementShowOutboundWorkflow.php',
- 'PhabricatorSMSManagementWorkflow' => 'infrastructure/sms/management/PhabricatorSMSManagementWorkflow.php',
- 'PhabricatorSMSSendWorker' => 'infrastructure/sms/worker/PhabricatorSMSSendWorker.php',
- 'PhabricatorSMSWorker' => 'infrastructure/sms/worker/PhabricatorSMSWorker.php',
'PhabricatorSQLPatchList' => 'infrastructure/storage/patch/PhabricatorSQLPatchList.php',
'PhabricatorSSHKeyGenerator' => 'infrastructure/util/PhabricatorSSHKeyGenerator.php',
'PhabricatorSSHKeysSettingsPanel' => 'applications/settings/panel/PhabricatorSSHKeysSettingsPanel.php',
@@ -10269,19 +10256,6 @@
'PhabricatorResourceSite' => 'PhabricatorSite',
'PhabricatorRobotsController' => 'PhabricatorController',
'PhabricatorS3FileStorageEngine' => 'PhabricatorFileStorageEngine',
- 'PhabricatorSMS' => 'PhabricatorSMSDAO',
- 'PhabricatorSMSConfigOptions' => 'PhabricatorApplicationConfigOptions',
- 'PhabricatorSMSDAO' => 'PhabricatorLiskDAO',
- 'PhabricatorSMSDemultiplexWorker' => 'PhabricatorSMSWorker',
- 'PhabricatorSMSImplementationAdapter' => 'Phobject',
- 'PhabricatorSMSImplementationTestBlackholeAdapter' => 'PhabricatorSMSImplementationAdapter',
- 'PhabricatorSMSImplementationTwilioAdapter' => 'PhabricatorSMSImplementationAdapter',
- 'PhabricatorSMSManagementListOutboundWorkflow' => 'PhabricatorSMSManagementWorkflow',
- 'PhabricatorSMSManagementSendTestWorkflow' => 'PhabricatorSMSManagementWorkflow',
- 'PhabricatorSMSManagementShowOutboundWorkflow' => 'PhabricatorSMSManagementWorkflow',
- 'PhabricatorSMSManagementWorkflow' => 'PhabricatorManagementWorkflow',
- 'PhabricatorSMSSendWorker' => 'PhabricatorSMSWorker',
- 'PhabricatorSMSWorker' => 'PhabricatorWorker',
'PhabricatorSQLPatchList' => 'Phobject',
'PhabricatorSSHKeyGenerator' => 'Phobject',
'PhabricatorSSHKeysSettingsPanel' => 'PhabricatorSettingsPanel',
diff --git a/src/applications/config/option/PhabricatorSMSConfigOptions.php b/src/applications/config/option/PhabricatorSMSConfigOptions.php
deleted file mode 100644
--- a/src/applications/config/option/PhabricatorSMSConfigOptions.php
+++ /dev/null
@@ -1,60 +0,0 @@
-<?php
-
-final class PhabricatorSMSConfigOptions
- extends PhabricatorApplicationConfigOptions {
-
- public function getName() {
- return pht('SMS');
- }
-
- public function getDescription() {
- return pht('Configure SMS.');
- }
-
- public function getIcon() {
- return 'fa-mobile';
- }
-
- public function getGroup() {
- return 'core';
- }
-
- public function getOptions() {
- $adapter_description = pht(
- 'Adapter class to use to transmit SMS to an external provider. A given '.
- 'external provider will most likely need more configuration which will '.
- 'most likely require registration and payment for the service.');
-
- return array(
- $this->newOption(
- 'sms.default-sender',
- 'string',
- null)
- ->setDescription(pht('Default "from" number.'))
- ->addExample('8675309', 'Jenny still has this number')
- ->addExample('18005555555', 'Maybe not a real number'),
- $this->newOption(
- 'sms.default-adapter',
- 'class',
- null)
- ->setBaseClass('PhabricatorSMSImplementationAdapter')
- ->setSummary(pht('Control how SMS is sent.'))
- ->setDescription($adapter_description),
- $this->newOption(
- 'twilio.account-sid',
- 'string',
- null)
- ->setDescription(pht('Account ID on Twilio service.'))
- ->setLocked(true)
- ->addExample('gf5kzccfn2sfknpnadvz7kokv6nz5v', pht('30 characters')),
- $this->newOption(
- 'twilio.auth-token',
- 'string',
- null)
- ->setDescription(pht('Authorization token from Twilio service.'))
- ->setHidden(true)
- ->addExample('f3jsi4i67wiwt6w54hf2zwvy3fjf5h', pht('30 characters')),
- );
- }
-
-}
diff --git a/src/infrastructure/sms/adapter/PhabricatorSMSImplementationAdapter.php b/src/infrastructure/sms/adapter/PhabricatorSMSImplementationAdapter.php
deleted file mode 100644
--- a/src/infrastructure/sms/adapter/PhabricatorSMSImplementationAdapter.php
+++ /dev/null
@@ -1,88 +0,0 @@
-<?php
-
-abstract class PhabricatorSMSImplementationAdapter extends Phobject {
-
- private $fromNumber;
- private $toNumber;
- private $body;
-
- public function setFrom($number) {
- $this->fromNumber = $number;
- return $this;
- }
-
- public function getFrom() {
- return $this->fromNumber;
- }
-
- public function setTo($number) {
- $this->toNumber = $number;
- return $this;
- }
-
- public function getTo() {
- return $this->toNumber;
- }
-
- public function setBody($body) {
- $this->body = $body;
- return $this;
- }
-
- public function getBody() {
- return $this->body;
- }
-
- /**
- * 16 characters or less, to be used in database columns and exposed
- * to administrators during configuration directly.
- */
- abstract public function getProviderShortName();
-
- /**
- * Send the message. Generally, this means connecting to some service and
- * handing data to it. SMS APIs are generally asynchronous, so truly
- * determining success or failure is probably impossible synchronously.
- *
- * That said, if the adapter determines that the SMS will never be
- * deliverable, or there is some other known failure, it should throw
- * an exception.
- *
- * @return null
- */
- abstract public function send();
-
- /**
- * Most (all?) SMS APIs are asynchronous, but some do send back some
- * initial information. Use this hook to determine what the updated
- * sentStatus should be and what the provider is using for an SMS ID,
- * as well as throw exceptions if there are any failures.
- *
- * @return array Tuple of ($sms_id and $sent_status)
- */
- abstract public function getSMSDataFromResult($result);
-
- /**
- * Due to the asynchronous nature of sending SMS messages, it can be
- * necessary to poll the provider regarding the sent status of a given
- * sms.
- *
- * For now, this *MUST* be implemented and *MUST* work.
- */
- abstract public function pollSMSSentStatus(PhabricatorSMS $sms);
-
- /**
- * Convenience function to handle sending an SMS.
- */
- public static function sendSMS(array $to_numbers, $body) {
- PhabricatorWorker::scheduleTask(
- 'PhabricatorSMSDemultiplexWorker',
- array(
- 'toNumbers' => $to_numbers,
- 'body' => $body,
- ),
- array(
- 'priority' => PhabricatorWorker::PRIORITY_ALERTS,
- ));
- }
-}
diff --git a/src/infrastructure/sms/adapter/PhabricatorSMSImplementationTestBlackholeAdapter.php b/src/infrastructure/sms/adapter/PhabricatorSMSImplementationTestBlackholeAdapter.php
deleted file mode 100644
--- a/src/infrastructure/sms/adapter/PhabricatorSMSImplementationTestBlackholeAdapter.php
+++ /dev/null
@@ -1,31 +0,0 @@
-<?php
-
-/**
- * This is useful for testing, but otherwise your SMS ends up in a blackhole.
- */
-final class PhabricatorSMSImplementationTestBlackholeAdapter
- extends PhabricatorSMSImplementationAdapter {
-
- public function getProviderShortName() {
- return 'testtesttest';
- }
-
- public function send() {
- // I guess this is what a blackhole looks like
- }
-
- public function getSMSDataFromResult($result) {
- return array(
- Filesystem::readRandomCharacters(40),
- PhabricatorSMS::STATUS_SENT,
- );
- }
-
- public function pollSMSSentStatus(PhabricatorSMS $sms) {
- if ($sms->getID()) {
- return PhabricatorSMS::STATUS_SENT;
- }
- return PhabricatorSMS::STATUS_SENT_UNCONFIRMED;
- }
-
-}
diff --git a/src/infrastructure/sms/adapter/PhabricatorSMSImplementationTwilioAdapter.php b/src/infrastructure/sms/adapter/PhabricatorSMSImplementationTwilioAdapter.php
deleted file mode 100644
--- a/src/infrastructure/sms/adapter/PhabricatorSMSImplementationTwilioAdapter.php
+++ /dev/null
@@ -1,99 +0,0 @@
-<?php
-
-final class PhabricatorSMSImplementationTwilioAdapter
- extends PhabricatorSMSImplementationAdapter {
-
- public function getProviderShortName() {
- return 'twilio';
- }
-
- /**
- * @phutil-external-symbol class Services_Twilio
- */
- private function buildClient() {
- $root = dirname(phutil_get_library_root('phabricator'));
- require_once $root.'/externals/twilio-php/Services/Twilio.php';
- $account_sid = PhabricatorEnv::getEnvConfig('twilio.account-sid');
- $auth_token = PhabricatorEnv::getEnvConfig('twilio.auth-token');
- return new Services_Twilio($account_sid, $auth_token);
- }
-
- /**
- * @phutil-external-symbol class Services_Twilio_RestException
- */
- public function send() {
- $client = $this->buildClient();
-
- try {
- $message = $client->account->sms_messages->create(
- $this->formatNumberForSMS($this->getFrom()),
- $this->formatNumberForSMS($this->getTo()),
- $this->getBody(),
- array());
- } catch (Services_Twilio_RestException $e) {
- $message = sprintf(
- 'HTTP Code %d: %s',
- $e->getStatus(),
- $e->getMessage());
-
- // Twilio tries to provide a link to more specific details if they can.
- if ($e->getInfo()) {
- $message .= sprintf(' For more information, see %s.', $e->getInfo());
- }
- throw new PhabricatorWorkerPermanentFailureException($message);
- }
- return $message;
- }
-
- public function getSMSDataFromResult($result) {
- return array($result->sid, $this->getSMSStatus($result->status));
- }
-
- public function pollSMSSentStatus(PhabricatorSMS $sms) {
- $client = $this->buildClient();
- $message = $client->account->messages->get($sms->getProviderSMSID());
-
- return $this->getSMSStatus($message->status);
- }
-
- /**
- * See https://www.twilio.com/docs/api/rest/sms#sms-status-values.
- */
- private function getSMSStatus($twilio_status) {
- switch ($twilio_status) {
- case 'failed':
- $status = PhabricatorSMS::STATUS_FAILED;
- break;
- case 'sent':
- $status = PhabricatorSMS::STATUS_SENT;
- break;
- case 'sending':
- case 'queued':
- default:
- $status = PhabricatorSMS::STATUS_SENT_UNCONFIRMED;
- break;
- }
- return $status;
- }
-
- /**
- * We expect numbers to be plainly entered - i.e. the preg_replace here
- * should do nothing - but try hard to format anyway.
- *
- * Twilio uses E164 format, e.g. +15551234567
- */
- private function formatNumberForSMS($number) {
- $number = preg_replace('/[^0-9]/', '', $number);
- $first_char = substr($number, 0, 1);
- switch ($first_char) {
- case '1':
- $prepend = '+';
- break;
- default:
- $prepend = '+1';
- break;
- }
- return $prepend.$number;
- }
-
-}
diff --git a/src/infrastructure/sms/management/PhabricatorSMSManagementListOutboundWorkflow.php b/src/infrastructure/sms/management/PhabricatorSMSManagementListOutboundWorkflow.php
deleted file mode 100644
--- a/src/infrastructure/sms/management/PhabricatorSMSManagementListOutboundWorkflow.php
+++ /dev/null
@@ -1,54 +0,0 @@
-<?php
-
-final class PhabricatorSMSManagementListOutboundWorkflow
- extends PhabricatorSMSManagementWorkflow {
-
- protected function didConstruct() {
- $this
- ->setName('list-outbound')
- ->setSynopsis(pht('List outbound SMS messages sent by Phabricator.'))
- ->setExamples('**list-outbound**')
- ->setArguments(
- array(
- array(
- 'name' => 'limit',
- 'param' => 'N',
- 'default' => 100,
- 'help' => pht(
- 'Show a specific number of SMS messages (default 100).'),
- ),
- ));
- }
-
- public function execute(PhutilArgumentParser $args) {
- $console = PhutilConsole::getConsole();
- $viewer = $this->getViewer();
-
- $sms_messages = id(new PhabricatorSMS())->loadAllWhere(
- '1 = 1 ORDER BY id DESC LIMIT %d',
- $args->getArg('limit'));
-
- if (!$sms_messages) {
- $console->writeErr("%s\n", pht('No sent SMS.'));
- return 0;
- }
-
- $table = id(new PhutilConsoleTable())
- ->setShowHeader(false)
- ->addColumn('id', array('title' => pht('ID')))
- ->addColumn('status', array('title' => pht('Status')))
- ->addColumn('recv', array('title' => pht('Recipient')));
-
- foreach (array_reverse($sms_messages) as $sms) {
- $table->addRow(array(
- 'id' => $sms->getID(),
- 'status' => $sms->getSendStatus(),
- 'recv' => $sms->getToNumber(),
- ));
- }
-
- $table->draw();
- return 0;
- }
-
-}
diff --git a/src/infrastructure/sms/management/PhabricatorSMSManagementSendTestWorkflow.php b/src/infrastructure/sms/management/PhabricatorSMSManagementSendTestWorkflow.php
deleted file mode 100644
--- a/src/infrastructure/sms/management/PhabricatorSMSManagementSendTestWorkflow.php
+++ /dev/null
@@ -1,47 +0,0 @@
-<?php
-
-final class PhabricatorSMSManagementSendTestWorkflow
- extends PhabricatorSMSManagementWorkflow {
-
- protected function didConstruct() {
- $this
- ->setName('send-test')
- ->setSynopsis(
- pht(
- 'Simulate sending an SMS. This may be useful to test your SMS '.
- 'configuration, or while developing new SMS adapters.'))
- ->setExamples("**send-test** --to 12345678 --body 'pizza time yet?'")
- ->setArguments(
- array(
- array(
- 'name' => 'to',
- 'param' => 'number',
- 'help' => pht('Send SMS "To:" the specified number.'),
- 'repeat' => true,
- ),
- array(
- 'name' => 'body',
- 'param' => 'text',
- 'help' => pht('Send SMS with the specified body.'),
- ),
- ));
- }
-
- public function execute(PhutilArgumentParser $args) {
- $console = PhutilConsole::getConsole();
- $viewer = $this->getViewer();
-
- $tos = $args->getArg('to');
- $body = $args->getArg('body');
-
- PhabricatorWorker::setRunAllTasksInProcess(true);
- PhabricatorSMSImplementationAdapter::sendSMS($tos, $body);
-
- $console->writeErr(
- "%s\n\n phabricator/ $ ./bin/sms list-outbound \n\n",
- pht(
- 'Send completed! You can view the list of SMS messages sent by '.
- 'running this command:'));
- }
-
-}
diff --git a/src/infrastructure/sms/management/PhabricatorSMSManagementShowOutboundWorkflow.php b/src/infrastructure/sms/management/PhabricatorSMSManagementShowOutboundWorkflow.php
deleted file mode 100644
--- a/src/infrastructure/sms/management/PhabricatorSMSManagementShowOutboundWorkflow.php
+++ /dev/null
@@ -1,72 +0,0 @@
-<?php
-
-final class PhabricatorSMSManagementShowOutboundWorkflow
- extends PhabricatorSMSManagementWorkflow {
-
- protected function didConstruct() {
- $this
- ->setName('show-outbound')
- ->setSynopsis(pht('Show diagnostic details about outbound SMS.'))
- ->setExamples(
- '**show-outbound** --id 1 --id 2')
- ->setArguments(
- array(
- array(
- 'name' => 'id',
- 'param' => 'id',
- 'help' => pht('Show details about outbound SMS with given ID.'),
- 'repeat' => true,
- ),
- ));
- }
-
- public function execute(PhutilArgumentParser $args) {
- $console = PhutilConsole::getConsole();
-
- $ids = $args->getArg('id');
- if (!$ids) {
- throw new PhutilArgumentUsageException(
- pht(
- "Use the '%s' flag to specify one or more SMS messages to show.",
- '--id'));
- }
-
- $messages = id(new PhabricatorSMS())->loadAllWhere(
- 'id IN (%Ld)',
- $ids);
-
- if ($ids) {
- $ids = array_fuse($ids);
- $missing = array_diff_key($ids, $messages);
- if ($missing) {
- throw new PhutilArgumentUsageException(
- pht(
- 'Some specified SMS messages do not exist: %s',
- implode(', ', array_keys($missing))));
- }
- }
-
- $last_key = last_key($messages);
- foreach ($messages as $message_key => $message) {
- $info = array();
-
- $info[] = pht('PROPERTIES');
- $info[] = pht('ID: %d', $message->getID());
- $info[] = pht('Status: %s', $message->getSendStatus());
- $info[] = pht('To: %s', $message->getToNumber());
- $info[] = pht('From: %s', $message->getFromNumber());
-
- $info[] = null;
- $info[] = pht('BODY');
- $info[] = $message->getBody();
- $info[] = null;
-
- $console->writeOut('%s', implode("\n", $info));
-
- if ($message_key != $last_key) {
- $console->writeOut("\n%s\n\n", str_repeat('-', 80));
- }
- }
- }
-
-}
diff --git a/src/infrastructure/sms/management/PhabricatorSMSManagementWorkflow.php b/src/infrastructure/sms/management/PhabricatorSMSManagementWorkflow.php
deleted file mode 100644
--- a/src/infrastructure/sms/management/PhabricatorSMSManagementWorkflow.php
+++ /dev/null
@@ -1,4 +0,0 @@
-<?php
-
-abstract class PhabricatorSMSManagementWorkflow
- extends PhabricatorManagementWorkflow {}
diff --git a/src/infrastructure/sms/storage/PhabricatorSMS.php b/src/infrastructure/sms/storage/PhabricatorSMS.php
deleted file mode 100644
--- a/src/infrastructure/sms/storage/PhabricatorSMS.php
+++ /dev/null
@@ -1,75 +0,0 @@
-<?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(self::STATUS_UNSENT)
- ->setProviderShortName(self::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() !=
- self::SHORTNAME_PLACEHOLDER);
- }
-}
diff --git a/src/infrastructure/sms/storage/PhabricatorSMSDAO.php b/src/infrastructure/sms/storage/PhabricatorSMSDAO.php
deleted file mode 100644
--- a/src/infrastructure/sms/storage/PhabricatorSMSDAO.php
+++ /dev/null
@@ -1,11 +0,0 @@
-<?php
-
-abstract class PhabricatorSMSDAO
- extends PhabricatorLiskDAO {
-
-
- public function getApplicationName() {
- return 'metamta';
- }
-
-}
diff --git a/src/infrastructure/sms/worker/PhabricatorSMSDemultiplexWorker.php b/src/infrastructure/sms/worker/PhabricatorSMSDemultiplexWorker.php
deleted file mode 100644
--- a/src/infrastructure/sms/worker/PhabricatorSMSDemultiplexWorker.php
+++ /dev/null
@@ -1,30 +0,0 @@
-<?php
-
-final class PhabricatorSMSDemultiplexWorker extends PhabricatorSMSWorker {
-
- protected function doWork() {
- $viewer = PhabricatorUser::getOmnipotentUser();
-
- $task_data = $this->getTaskData();
-
- $to_numbers = idx($task_data, 'toNumbers');
- if (!$to_numbers) {
- // If we don't have any to numbers, don't send any sms.
- return;
- }
-
- foreach ($to_numbers as $number) {
- // NOTE: we will set the fromNumber and the proper provider data
- // in the `PhabricatorSMSSendWorker`.
- $sms = PhabricatorSMS::initializeNewSMS($task_data['body']);
- $sms->setToNumber($number);
- $sms->save();
- $this->queueTask(
- 'PhabricatorSMSSendWorker',
- array(
- 'smsID' => $sms->getID(),
- ));
- }
- }
-
-}
diff --git a/src/infrastructure/sms/worker/PhabricatorSMSSendWorker.php b/src/infrastructure/sms/worker/PhabricatorSMSSendWorker.php
deleted file mode 100644
--- a/src/infrastructure/sms/worker/PhabricatorSMSSendWorker.php
+++ /dev/null
@@ -1,85 +0,0 @@
-<?php
-
-final class PhabricatorSMSSendWorker extends PhabricatorSMSWorker {
-
- public function getMaximumRetryCount() {
- return PhabricatorSMS::MAXIMUM_SEND_TRIES;
- }
-
- public function getWaitBeforeRetry(PhabricatorWorkerTask $task) {
- return phutil_units('1 minute in seconds');
- }
-
- protected function doWork() {
- $viewer = PhabricatorUser::getOmnipotentUser();
-
- $task_data = $this->getTaskData();
-
- $sms = id(new PhabricatorSMS())
- ->loadOneWhere('id = %d', $task_data['smsID']);
-
- if (!$sms) {
- throw new PhabricatorWorkerPermanentFailureException(
- pht('SMS object was not found.'));
- }
-
- // this has the potential to be updated asynchronously
- if ($sms->getSendStatus() == PhabricatorSMS::STATUS_SENT) {
- return;
- }
-
- $adapter = PhabricatorEnv::getEnvConfig('sms.default-adapter');
- $adapter = newv($adapter, array());
- if ($sms->hasBeenSentAtLeastOnce()) {
- $up_to_date_status = $adapter->pollSMSSentStatus($sms);
- if ($up_to_date_status) {
- $sms->setSendStatus($up_to_date_status);
- if ($up_to_date_status == PhabricatorSMS::STATUS_SENT) {
- $sms->save();
- return;
- }
- }
- // TODO - re-jigger this so we can try if appropos (e.g. rate limiting)
- return;
- }
-
- $from_number = PhabricatorEnv::getEnvConfig('sms.default-sender');
- // always set the from number if we get this far in case of configuration
- // changes.
- $sms->setFromNumber($from_number);
-
- $adapter->setTo($sms->getToNumber());
- $adapter->setFrom($sms->getFromNumber());
- $adapter->setBody($sms->getBody());
- // give the provider name the same treatment as phone number
- $sms->setProviderShortName($adapter->getProviderShortName());
-
- if (PhabricatorEnv::getEnvConfig('phabricator.silent')) {
- $sms->setSendStatus(PhabricatorSMS::STATUS_FAILED_PERMANENTLY);
- $sms->save();
- throw new PhabricatorWorkerPermanentFailureException(
- pht(
- 'Phabricator is running in silent mode. See `%s` '.
- 'in the configuration to change this setting.',
- 'phabricator.silent'));
- }
-
- try {
- $result = $adapter->send();
- list($sms_id, $sent_status) = $adapter->getSMSDataFromResult($result);
- } catch (PhabricatorWorkerPermanentFailureException $e) {
- $sms->setSendStatus(PhabricatorSMS::STATUS_FAILED_PERMANENTLY);
- $sms->save();
- throw $e;
- } catch (Exception $e) {
- $sms->setSendStatus(PhabricatorSMS::STATUS_FAILED_PERMANENTLY);
- $sms->save();
- throw new PhabricatorWorkerPermanentFailureException(
- $e->getMessage());
- }
- $sms->setProviderSMSID($sms_id);
- $sms->setSendStatus($sent_status);
- $sms->save();
- }
-
-}
diff --git a/src/infrastructure/sms/worker/PhabricatorSMSWorker.php b/src/infrastructure/sms/worker/PhabricatorSMSWorker.php
deleted file mode 100644
--- a/src/infrastructure/sms/worker/PhabricatorSMSWorker.php
+++ /dev/null
@@ -1,4 +0,0 @@
-<?php
-
-abstract class PhabricatorSMSWorker
- extends PhabricatorWorker {}

File Metadata

Mime Type
text/plain
Expires
Thu, Mar 13, 5:48 AM (1 w, 3 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7607475
Default Alt Text
D19939.diff (26 KB)

Event Timeline