@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.

Define Differential email action in terms of EditEngine

Summary: Ref T11114. Move email/command actions, like "!reject", to modular transactions + editengine.

Test Plan: Used `bin/mail receive-test` to pipe "!stuff" to an object, saw appropraite effects in web UI.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T11114

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

+124 -53
+16 -53
src/applications/differential/command/DifferentialActionEmailCommand.php
··· 55 55 } 56 56 57 57 public function getCommandObjects() { 58 - $actions = array( 59 - DifferentialAction::ACTION_REJECT => 'request', 60 - DifferentialAction::ACTION_ABANDON => 'abandon', 61 - DifferentialAction::ACTION_RECLAIM => 'reclaim', 62 - DifferentialAction::ACTION_RESIGN => 'resign', 63 - DifferentialAction::ACTION_RETHINK => 'planchanges', 64 - DifferentialAction::ACTION_CLAIM => 'commandeer', 65 - ); 58 + $actions = DifferentialRevisionActionTransaction::loadAllActions(); 59 + $actions = msort($actions, 'getRevisionActionOrderVector'); 66 60 67 - if (PhabricatorEnv::getEnvConfig('differential.enable-email-accept')) { 68 - $actions[DifferentialAction::ACTION_ACCEPT] = 'accept'; 69 - } 61 + $objects = array(); 62 + foreach ($actions as $action) { 63 + $keyword = $action->getCommandKeyword(); 64 + if ($keyword === null) { 65 + continue; 66 + } 70 67 71 - $aliases = array( 72 - DifferentialAction::ACTION_REJECT => array('reject'), 73 - DifferentialAction::ACTION_CLAIM => array('claim'), 74 - DifferentialAction::ACTION_RETHINK => array('rethink'), 75 - ); 68 + $aliases = $action->getCommandAliases(); 69 + $summary = $action->getCommandSummary(); 76 70 77 - $summaries = array( 78 - DifferentialAction::ACTION_REJECT => 79 - pht('Request changes to a revision.'), 80 - DifferentialAction::ACTION_ABANDON => 81 - pht('Abandon a revision.'), 82 - DifferentialAction::ACTION_RECLAIM => 83 - pht('Reclaim a revision.'), 84 - DifferentialAction::ACTION_RESIGN => 85 - pht('Resign from a revision.'), 86 - DifferentialAction::ACTION_RETHINK => 87 - pht('Plan changes to a revision.'), 88 - DifferentialAction::ACTION_CLAIM => 89 - pht('Commandeer a revision.'), 90 - DifferentialAction::ACTION_ACCEPT => 91 - pht('Accept a revision.'), 92 - ); 93 - 94 - $descriptions = array( 95 - 96 - ); 97 - 98 - $objects = array(); 99 - foreach ($actions as $action => $keyword) { 100 - $object = id(new DifferentialActionEmailCommand()) 71 + $object = id(new self()) 101 72 ->setCommand($keyword) 102 - ->setAction($action) 103 - ->setCommandSummary($summaries[$action]); 104 - 105 - if (isset($aliases[$action])) { 106 - $object->setCommandAliases($aliases[$action]); 107 - } 108 - 109 - if (isset($descriptions[$action])) { 110 - $object->setCommandDescription($descriptions[$action]); 111 - } 73 + ->setCommandAliases($aliases) 74 + ->setAction($action->getTransactionTypeConstant()) 75 + ->setCommandSummary($summary); 112 76 113 77 $objects[] = $object; 114 78 } 115 - 116 79 117 80 return $objects; 118 81 } ··· 131 94 $xactions = array(); 132 95 133 96 $xactions[] = $object->getApplicationTransactionTemplate() 134 - ->setTransactionType(DifferentialTransaction::TYPE_ACTION) 135 - ->setNewValue($this->getAction()); 97 + ->setTransactionType($this->getAction()) 98 + ->setNewValue(true); 136 99 137 100 return $xactions; 138 101 }
+12
src/applications/differential/xaction/DifferentialRevisionAbandonTransaction.php
··· 26 26 return 500; 27 27 } 28 28 29 + public function getCommandKeyword() { 30 + return 'abandon'; 31 + } 32 + 33 + public function getCommandAliases() { 34 + return array(); 35 + } 36 + 37 + public function getCommandSummary() { 38 + return pht('Abandon a revision.'); 39 + } 40 + 29 41 public function generateOldValue($object) { 30 42 return $object->isAbandoned(); 31 43 }
+18
src/applications/differential/xaction/DifferentialRevisionAcceptTransaction.php
··· 26 26 return 500; 27 27 } 28 28 29 + public function getCommandKeyword() { 30 + $accept_key = 'differential.enable-email-accept'; 31 + $allow_email_accept = PhabricatorEnv::getEnvConfig($accept_key); 32 + if (!$allow_email_accept) { 33 + return null; 34 + } 35 + 36 + return 'accept'; 37 + } 38 + 39 + public function getCommandAliases() { 40 + return array(); 41 + } 42 + 43 + public function getCommandSummary() { 44 + return pht('Accept a revision.'); 45 + } 46 + 29 47 public function generateOldValue($object) { 30 48 $actor = $this->getActor(); 31 49 return $this->isViewerAcceptingReviewer($object, $actor);
+12
src/applications/differential/xaction/DifferentialRevisionActionTransaction.php
··· 19 19 abstract protected function validateAction($object, PhabricatorUser $viewer); 20 20 abstract protected function getRevisionActionLabel(); 21 21 22 + public function getCommandKeyword() { 23 + return null; 24 + } 25 + 26 + public function getCommandAliases() { 27 + return array(); 28 + } 29 + 30 + public function getCommandSummary() { 31 + return null; 32 + } 33 + 22 34 protected function getRevisionActionOrder() { 23 35 return 1000; 24 36 }
+14
src/applications/differential/xaction/DifferentialRevisionCommandeerTransaction.php
··· 26 26 return 700; 27 27 } 28 28 29 + public function getCommandKeyword() { 30 + return 'commandeer'; 31 + } 32 + 33 + public function getCommandAliases() { 34 + return array( 35 + 'claim', 36 + ); 37 + } 38 + 39 + public function getCommandSummary() { 40 + return pht('Commadeer a revision.'); 41 + } 42 + 29 43 public function generateOldValue($object) { 30 44 return $object->getAuthorPHID(); 31 45 }
+14
src/applications/differential/xaction/DifferentialRevisionPlanChangesTransaction.php
··· 27 27 return 200; 28 28 } 29 29 30 + public function getCommandKeyword() { 31 + return 'planchanges'; 32 + } 33 + 34 + public function getCommandAliases() { 35 + return array( 36 + 'rethink', 37 + ); 38 + } 39 + 40 + public function getCommandSummary() { 41 + return pht('Plan changes to a revision.'); 42 + } 43 + 30 44 public function generateOldValue($object) { 31 45 $status_planned = ArcanistDifferentialRevisionStatus::CHANGES_PLANNED; 32 46 return ($object->getStatus() == $status_planned);
+12
src/applications/differential/xaction/DifferentialRevisionReclaimTransaction.php
··· 26 26 return 600; 27 27 } 28 28 29 + public function getCommandKeyword() { 30 + return 'reclaim'; 31 + } 32 + 33 + public function getCommandAliases() { 34 + return array(); 35 + } 36 + 37 + public function getCommandSummary() { 38 + return pht('Reclaim a revision.'); 39 + } 40 + 29 41 public function generateOldValue($object) { 30 42 return !$object->isAbandoned(); 31 43 }
+14
src/applications/differential/xaction/DifferentialRevisionRejectTransaction.php
··· 26 26 return 600; 27 27 } 28 28 29 + public function getCommandKeyword() { 30 + return 'request'; 31 + } 32 + 33 + public function getCommandAliases() { 34 + return array( 35 + 'reject', 36 + ); 37 + } 38 + 39 + public function getCommandSummary() { 40 + return pht('Request changes to a revision.'); 41 + } 42 + 29 43 public function generateOldValue($object) { 30 44 $actor = $this->getActor(); 31 45 return $this->isViewerRejectingReviewer($object, $actor);
+12
src/applications/differential/xaction/DifferentialRevisionResignTransaction.php
··· 26 26 return 700; 27 27 } 28 28 29 + public function getCommandKeyword() { 30 + return 'resign'; 31 + } 32 + 33 + public function getCommandAliases() { 34 + return array(); 35 + } 36 + 37 + public function getCommandSummary() { 38 + return pht('Resign from a revision.'); 39 + } 40 + 29 41 public function generateOldValue($object) { 30 42 $actor = $this->getActor(); 31 43 return !$this->isViewerAnyReviewer($object, $actor);