Page MenuHomePhabricator

D20025.diff
No OneTemporary

D20025.diff

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
@@ -2212,6 +2212,7 @@
'PhabricatorAuthContactNumberPrimaryTransaction' => 'applications/auth/xaction/PhabricatorAuthContactNumberPrimaryTransaction.php',
'PhabricatorAuthContactNumberQuery' => 'applications/auth/query/PhabricatorAuthContactNumberQuery.php',
'PhabricatorAuthContactNumberStatusTransaction' => 'applications/auth/xaction/PhabricatorAuthContactNumberStatusTransaction.php',
+ 'PhabricatorAuthContactNumberTestController' => 'applications/auth/controller/contact/PhabricatorAuthContactNumberTestController.php',
'PhabricatorAuthContactNumberTransaction' => 'applications/auth/storage/PhabricatorAuthContactNumberTransaction.php',
'PhabricatorAuthContactNumberTransactionQuery' => 'applications/auth/query/PhabricatorAuthContactNumberTransactionQuery.php',
'PhabricatorAuthContactNumberTransactionType' => 'applications/auth/xaction/PhabricatorAuthContactNumberTransactionType.php',
@@ -2368,6 +2369,7 @@
'PhabricatorAuthTemporaryTokenType' => 'applications/auth/tokentype/PhabricatorAuthTemporaryTokenType.php',
'PhabricatorAuthTemporaryTokenTypeModule' => 'applications/auth/tokentype/PhabricatorAuthTemporaryTokenTypeModule.php',
'PhabricatorAuthTerminateSessionController' => 'applications/auth/controller/PhabricatorAuthTerminateSessionController.php',
+ 'PhabricatorAuthTestSMSAction' => 'applications/auth/action/PhabricatorAuthTestSMSAction.php',
'PhabricatorAuthTryFactorAction' => 'applications/auth/action/PhabricatorAuthTryFactorAction.php',
'PhabricatorAuthUnlinkController' => 'applications/auth/controller/PhabricatorAuthUnlinkController.php',
'PhabricatorAuthValidateController' => 'applications/auth/controller/PhabricatorAuthValidateController.php',
@@ -7924,6 +7926,7 @@
'PhabricatorAuthContactNumberPrimaryTransaction' => 'PhabricatorAuthContactNumberTransactionType',
'PhabricatorAuthContactNumberQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'PhabricatorAuthContactNumberStatusTransaction' => 'PhabricatorAuthContactNumberTransactionType',
+ 'PhabricatorAuthContactNumberTestController' => 'PhabricatorAuthContactNumberController',
'PhabricatorAuthContactNumberTransaction' => 'PhabricatorModularTransaction',
'PhabricatorAuthContactNumberTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
'PhabricatorAuthContactNumberTransactionType' => 'PhabricatorModularTransactionType',
@@ -8116,6 +8119,7 @@
'PhabricatorAuthTemporaryTokenType' => 'Phobject',
'PhabricatorAuthTemporaryTokenTypeModule' => 'PhabricatorConfigModule',
'PhabricatorAuthTerminateSessionController' => 'PhabricatorAuthController',
+ 'PhabricatorAuthTestSMSAction' => 'PhabricatorSystemAction',
'PhabricatorAuthTryFactorAction' => 'PhabricatorSystemAction',
'PhabricatorAuthUnlinkController' => 'PhabricatorAuthController',
'PhabricatorAuthValidateController' => 'PhabricatorAuthController',
diff --git a/src/applications/auth/action/PhabricatorAuthTestSMSAction.php b/src/applications/auth/action/PhabricatorAuthTestSMSAction.php
new file mode 100644
--- /dev/null
+++ b/src/applications/auth/action/PhabricatorAuthTestSMSAction.php
@@ -0,0 +1,22 @@
+<?php
+
+final class PhabricatorAuthTestSMSAction extends PhabricatorSystemAction {
+
+ const TYPECONST = 'auth.sms.test';
+
+ public function getActionConstant() {
+ return self::TYPECONST;
+ }
+
+ public function getScoreThreshold() {
+ return 60 / phutil_units('1 hour in seconds');
+ }
+
+ public function getLimitExplanation() {
+ return pht(
+ 'You and other users on this install are collectively sending too '.
+ 'many test text messages too quickly. Wait a few minutes to continue '.
+ 'texting tests.');
+ }
+
+}
diff --git a/src/applications/auth/application/PhabricatorAuthApplication.php b/src/applications/auth/application/PhabricatorAuthApplication.php
--- a/src/applications/auth/application/PhabricatorAuthApplication.php
+++ b/src/applications/auth/application/PhabricatorAuthApplication.php
@@ -115,6 +115,8 @@
'PhabricatorAuthContactNumberDisableController',
'primary/(?P<id>[1-9]\d*)/' =>
'PhabricatorAuthContactNumberPrimaryController',
+ 'test/(?P<id>[1-9]\d*)/' =>
+ 'PhabricatorAuthContactNumberTestController',
),
),
diff --git a/src/applications/auth/controller/contact/PhabricatorAuthContactNumberTestController.php b/src/applications/auth/controller/contact/PhabricatorAuthContactNumberTestController.php
new file mode 100644
--- /dev/null
+++ b/src/applications/auth/controller/contact/PhabricatorAuthContactNumberTestController.php
@@ -0,0 +1,64 @@
+<?php
+
+final class PhabricatorAuthContactNumberTestController
+ extends PhabricatorAuthContactNumberController {
+
+ public function handleRequest(AphrontRequest $request) {
+ $viewer = $request->getViewer();
+ $id = $request->getURIData('id');
+
+ $number = id(new PhabricatorAuthContactNumberQuery())
+ ->setViewer($viewer)
+ ->withIDs(array($id))
+ ->requireCapabilities(
+ array(
+ PhabricatorPolicyCapability::CAN_VIEW,
+ PhabricatorPolicyCapability::CAN_EDIT,
+ ))
+ ->executeOne();
+ if (!$number) {
+ return new Aphront404Response();
+ }
+
+ $id = $number->getID();
+ $cancel_uri = $number->getURI();
+
+ // NOTE: This is a global limit shared by all users.
+ PhabricatorSystemActionEngine::willTakeAction(
+ array(id(new PhabricatorAuthApplication())->getPHID()),
+ new PhabricatorAuthTestSMSAction(),
+ 1);
+
+ if ($request->isFormPost()) {
+ $uri = PhabricatorEnv::getURI('/');
+ $uri = new PhutilURI($uri);
+
+ $mail = id(new PhabricatorMetaMTAMail())
+ ->setMessageType(PhabricatorMailSMSMessage::MESSAGETYPE)
+ ->addTos(array($viewer->getPHID()))
+ ->setSensitiveContent(false)
+ ->setBody(
+ pht(
+ 'This is a terse test text message from Phabricator (%s).',
+ $uri->getDomain()))
+ ->save();
+
+ return id(new AphrontRedirectResponse())->setURI($mail->getURI());
+ }
+
+ $number_display = phutil_tag(
+ 'strong',
+ array(),
+ $number->getDisplayName());
+
+ return $this->newDialog()
+ ->setTitle(pht('Set Test Message'))
+ ->appendParagraph(
+ pht(
+ 'Send a test message to %s?',
+ $number_display))
+ ->addSubmitButton(pht('Send SMS'))
+ ->addCancelButton($cancel_uri);
+ }
+
+}
diff --git a/src/applications/auth/controller/contact/PhabricatorAuthContactNumberViewController.php b/src/applications/auth/controller/contact/PhabricatorAuthContactNumberViewController.php
--- a/src/applications/auth/controller/contact/PhabricatorAuthContactNumberViewController.php
+++ b/src/applications/auth/controller/contact/PhabricatorAuthContactNumberViewController.php
@@ -98,6 +98,14 @@
->setDisabled(!$can_edit)
->setWorkflow(!$can_edit));
+ $curtain->addAction(
+ id(new PhabricatorActionView())
+ ->setName(pht('Send Test Message'))
+ ->setIcon('fa-envelope-o')
+ ->setHref($this->getApplicationURI("contact/test/{$id}/"))
+ ->setDisabled(!$can_edit)
+ ->setWorkflow(true));
+
if ($number->isDisabled()) {
$disable_uri = $this->getApplicationURI("contact/enable/{$id}/");
$disable_name = pht('Enable Contact Number');
diff --git a/src/applications/metamta/controller/PhabricatorMetaMTAMailViewController.php b/src/applications/metamta/controller/PhabricatorMetaMTAMailViewController.php
--- a/src/applications/metamta/controller/PhabricatorMetaMTAMailViewController.php
+++ b/src/applications/metamta/controller/PhabricatorMetaMTAMailViewController.php
@@ -187,6 +187,9 @@
->setStacked(true);
$headers = $mail->getDeliveredHeaders();
+ if (!$headers) {
+ $headers = array();
+ }
// Sort headers by name.
$headers = isort($headers, 0);

File Metadata

Mime Type
text/plain
Expires
Mon, Dec 23, 4:03 PM (18 h, 31 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6921559
Default Alt Text
D20025.diff (7 KB)

Event Timeline