@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 a "test message" action for contact numbers

Summary: Depends on D20024. See D20022. Put something in place temporarily until we build out validation at some point.

Test Plan: Sent myself a test message.

Reviewers: amckinley

Reviewed By: amckinley

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

+103
+4
src/__phutil_library_map__.php
··· 2212 2212 'PhabricatorAuthContactNumberPrimaryTransaction' => 'applications/auth/xaction/PhabricatorAuthContactNumberPrimaryTransaction.php', 2213 2213 'PhabricatorAuthContactNumberQuery' => 'applications/auth/query/PhabricatorAuthContactNumberQuery.php', 2214 2214 'PhabricatorAuthContactNumberStatusTransaction' => 'applications/auth/xaction/PhabricatorAuthContactNumberStatusTransaction.php', 2215 + 'PhabricatorAuthContactNumberTestController' => 'applications/auth/controller/contact/PhabricatorAuthContactNumberTestController.php', 2215 2216 'PhabricatorAuthContactNumberTransaction' => 'applications/auth/storage/PhabricatorAuthContactNumberTransaction.php', 2216 2217 'PhabricatorAuthContactNumberTransactionQuery' => 'applications/auth/query/PhabricatorAuthContactNumberTransactionQuery.php', 2217 2218 'PhabricatorAuthContactNumberTransactionType' => 'applications/auth/xaction/PhabricatorAuthContactNumberTransactionType.php', ··· 2368 2369 'PhabricatorAuthTemporaryTokenType' => 'applications/auth/tokentype/PhabricatorAuthTemporaryTokenType.php', 2369 2370 'PhabricatorAuthTemporaryTokenTypeModule' => 'applications/auth/tokentype/PhabricatorAuthTemporaryTokenTypeModule.php', 2370 2371 'PhabricatorAuthTerminateSessionController' => 'applications/auth/controller/PhabricatorAuthTerminateSessionController.php', 2372 + 'PhabricatorAuthTestSMSAction' => 'applications/auth/action/PhabricatorAuthTestSMSAction.php', 2371 2373 'PhabricatorAuthTryFactorAction' => 'applications/auth/action/PhabricatorAuthTryFactorAction.php', 2372 2374 'PhabricatorAuthUnlinkController' => 'applications/auth/controller/PhabricatorAuthUnlinkController.php', 2373 2375 'PhabricatorAuthValidateController' => 'applications/auth/controller/PhabricatorAuthValidateController.php', ··· 7924 7926 'PhabricatorAuthContactNumberPrimaryTransaction' => 'PhabricatorAuthContactNumberTransactionType', 7925 7927 'PhabricatorAuthContactNumberQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 7926 7928 'PhabricatorAuthContactNumberStatusTransaction' => 'PhabricatorAuthContactNumberTransactionType', 7929 + 'PhabricatorAuthContactNumberTestController' => 'PhabricatorAuthContactNumberController', 7927 7930 'PhabricatorAuthContactNumberTransaction' => 'PhabricatorModularTransaction', 7928 7931 'PhabricatorAuthContactNumberTransactionQuery' => 'PhabricatorApplicationTransactionQuery', 7929 7932 'PhabricatorAuthContactNumberTransactionType' => 'PhabricatorModularTransactionType', ··· 8116 8119 'PhabricatorAuthTemporaryTokenType' => 'Phobject', 8117 8120 'PhabricatorAuthTemporaryTokenTypeModule' => 'PhabricatorConfigModule', 8118 8121 'PhabricatorAuthTerminateSessionController' => 'PhabricatorAuthController', 8122 + 'PhabricatorAuthTestSMSAction' => 'PhabricatorSystemAction', 8119 8123 'PhabricatorAuthTryFactorAction' => 'PhabricatorSystemAction', 8120 8124 'PhabricatorAuthUnlinkController' => 'PhabricatorAuthController', 8121 8125 'PhabricatorAuthValidateController' => 'PhabricatorAuthController',
+22
src/applications/auth/action/PhabricatorAuthTestSMSAction.php
··· 1 + <?php 2 + 3 + final class PhabricatorAuthTestSMSAction extends PhabricatorSystemAction { 4 + 5 + const TYPECONST = 'auth.sms.test'; 6 + 7 + public function getActionConstant() { 8 + return self::TYPECONST; 9 + } 10 + 11 + public function getScoreThreshold() { 12 + return 60 / phutil_units('1 hour in seconds'); 13 + } 14 + 15 + public function getLimitExplanation() { 16 + return pht( 17 + 'You and other users on this install are collectively sending too '. 18 + 'many test text messages too quickly. Wait a few minutes to continue '. 19 + 'texting tests.'); 20 + } 21 + 22 + }
+2
src/applications/auth/application/PhabricatorAuthApplication.php
··· 115 115 'PhabricatorAuthContactNumberDisableController', 116 116 'primary/(?P<id>[1-9]\d*)/' => 117 117 'PhabricatorAuthContactNumberPrimaryController', 118 + 'test/(?P<id>[1-9]\d*)/' => 119 + 'PhabricatorAuthContactNumberTestController', 118 120 ), 119 121 ), 120 122
+64
src/applications/auth/controller/contact/PhabricatorAuthContactNumberTestController.php
··· 1 + <?php 2 + 3 + final class PhabricatorAuthContactNumberTestController 4 + extends PhabricatorAuthContactNumberController { 5 + 6 + public function handleRequest(AphrontRequest $request) { 7 + $viewer = $request->getViewer(); 8 + $id = $request->getURIData('id'); 9 + 10 + $number = id(new PhabricatorAuthContactNumberQuery()) 11 + ->setViewer($viewer) 12 + ->withIDs(array($id)) 13 + ->requireCapabilities( 14 + array( 15 + PhabricatorPolicyCapability::CAN_VIEW, 16 + PhabricatorPolicyCapability::CAN_EDIT, 17 + )) 18 + ->executeOne(); 19 + if (!$number) { 20 + return new Aphront404Response(); 21 + } 22 + 23 + $id = $number->getID(); 24 + $cancel_uri = $number->getURI(); 25 + 26 + // NOTE: This is a global limit shared by all users. 27 + PhabricatorSystemActionEngine::willTakeAction( 28 + array(id(new PhabricatorAuthApplication())->getPHID()), 29 + new PhabricatorAuthTestSMSAction(), 30 + 1); 31 + 32 + if ($request->isFormPost()) { 33 + $uri = PhabricatorEnv::getURI('/'); 34 + $uri = new PhutilURI($uri); 35 + 36 + $mail = id(new PhabricatorMetaMTAMail()) 37 + ->setMessageType(PhabricatorMailSMSMessage::MESSAGETYPE) 38 + ->addTos(array($viewer->getPHID())) 39 + ->setSensitiveContent(false) 40 + ->setBody( 41 + pht( 42 + 'This is a terse test text message from Phabricator (%s).', 43 + $uri->getDomain())) 44 + ->save(); 45 + 46 + return id(new AphrontRedirectResponse())->setURI($mail->getURI()); 47 + } 48 + 49 + $number_display = phutil_tag( 50 + 'strong', 51 + array(), 52 + $number->getDisplayName()); 53 + 54 + return $this->newDialog() 55 + ->setTitle(pht('Set Test Message')) 56 + ->appendParagraph( 57 + pht( 58 + 'Send a test message to %s?', 59 + $number_display)) 60 + ->addSubmitButton(pht('Send SMS')) 61 + ->addCancelButton($cancel_uri); 62 + } 63 + 64 + }
+8
src/applications/auth/controller/contact/PhabricatorAuthContactNumberViewController.php
··· 98 98 ->setDisabled(!$can_edit) 99 99 ->setWorkflow(!$can_edit)); 100 100 101 + $curtain->addAction( 102 + id(new PhabricatorActionView()) 103 + ->setName(pht('Send Test Message')) 104 + ->setIcon('fa-envelope-o') 105 + ->setHref($this->getApplicationURI("contact/test/{$id}/")) 106 + ->setDisabled(!$can_edit) 107 + ->setWorkflow(true)); 108 + 101 109 if ($number->isDisabled()) { 102 110 $disable_uri = $this->getApplicationURI("contact/enable/{$id}/"); 103 111 $disable_name = pht('Enable Contact Number');
+3
src/applications/metamta/controller/PhabricatorMetaMTAMailViewController.php
··· 187 187 ->setStacked(true); 188 188 189 189 $headers = $mail->getDeliveredHeaders(); 190 + if (!$headers) { 191 + $headers = array(); 192 + } 190 193 191 194 // Sort headers by name. 192 195 $headers = isort($headers, 0);