mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-19 03:50:54 +01:00
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
This commit is contained in:
parent
35750b9c61
commit
50de3071ac
9 changed files with 125 additions and 54 deletions
|
@ -55,65 +55,28 @@ final class DifferentialActionEmailCommand
|
|||
}
|
||||
|
||||
public function getCommandObjects() {
|
||||
$actions = array(
|
||||
DifferentialAction::ACTION_REJECT => 'request',
|
||||
DifferentialAction::ACTION_ABANDON => 'abandon',
|
||||
DifferentialAction::ACTION_RECLAIM => 'reclaim',
|
||||
DifferentialAction::ACTION_RESIGN => 'resign',
|
||||
DifferentialAction::ACTION_RETHINK => 'planchanges',
|
||||
DifferentialAction::ACTION_CLAIM => 'commandeer',
|
||||
);
|
||||
|
||||
if (PhabricatorEnv::getEnvConfig('differential.enable-email-accept')) {
|
||||
$actions[DifferentialAction::ACTION_ACCEPT] = 'accept';
|
||||
}
|
||||
|
||||
$aliases = array(
|
||||
DifferentialAction::ACTION_REJECT => array('reject'),
|
||||
DifferentialAction::ACTION_CLAIM => array('claim'),
|
||||
DifferentialAction::ACTION_RETHINK => array('rethink'),
|
||||
);
|
||||
|
||||
$summaries = array(
|
||||
DifferentialAction::ACTION_REJECT =>
|
||||
pht('Request changes to a revision.'),
|
||||
DifferentialAction::ACTION_ABANDON =>
|
||||
pht('Abandon a revision.'),
|
||||
DifferentialAction::ACTION_RECLAIM =>
|
||||
pht('Reclaim a revision.'),
|
||||
DifferentialAction::ACTION_RESIGN =>
|
||||
pht('Resign from a revision.'),
|
||||
DifferentialAction::ACTION_RETHINK =>
|
||||
pht('Plan changes to a revision.'),
|
||||
DifferentialAction::ACTION_CLAIM =>
|
||||
pht('Commandeer a revision.'),
|
||||
DifferentialAction::ACTION_ACCEPT =>
|
||||
pht('Accept a revision.'),
|
||||
);
|
||||
|
||||
$descriptions = array(
|
||||
|
||||
);
|
||||
$actions = DifferentialRevisionActionTransaction::loadAllActions();
|
||||
$actions = msort($actions, 'getRevisionActionOrderVector');
|
||||
|
||||
$objects = array();
|
||||
foreach ($actions as $action => $keyword) {
|
||||
$object = id(new DifferentialActionEmailCommand())
|
||||
foreach ($actions as $action) {
|
||||
$keyword = $action->getCommandKeyword();
|
||||
if ($keyword === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$aliases = $action->getCommandAliases();
|
||||
$summary = $action->getCommandSummary();
|
||||
|
||||
$object = id(new self())
|
||||
->setCommand($keyword)
|
||||
->setAction($action)
|
||||
->setCommandSummary($summaries[$action]);
|
||||
|
||||
if (isset($aliases[$action])) {
|
||||
$object->setCommandAliases($aliases[$action]);
|
||||
}
|
||||
|
||||
if (isset($descriptions[$action])) {
|
||||
$object->setCommandDescription($descriptions[$action]);
|
||||
}
|
||||
->setCommandAliases($aliases)
|
||||
->setAction($action->getTransactionTypeConstant())
|
||||
->setCommandSummary($summary);
|
||||
|
||||
$objects[] = $object;
|
||||
}
|
||||
|
||||
|
||||
return $objects;
|
||||
}
|
||||
|
||||
|
@ -131,8 +94,8 @@ final class DifferentialActionEmailCommand
|
|||
$xactions = array();
|
||||
|
||||
$xactions[] = $object->getApplicationTransactionTemplate()
|
||||
->setTransactionType(DifferentialTransaction::TYPE_ACTION)
|
||||
->setNewValue($this->getAction());
|
||||
->setTransactionType($this->getAction())
|
||||
->setNewValue(true);
|
||||
|
||||
return $xactions;
|
||||
}
|
||||
|
|
|
@ -26,6 +26,18 @@ final class DifferentialRevisionAbandonTransaction
|
|||
return 500;
|
||||
}
|
||||
|
||||
public function getCommandKeyword() {
|
||||
return 'abandon';
|
||||
}
|
||||
|
||||
public function getCommandAliases() {
|
||||
return array();
|
||||
}
|
||||
|
||||
public function getCommandSummary() {
|
||||
return pht('Abandon a revision.');
|
||||
}
|
||||
|
||||
public function generateOldValue($object) {
|
||||
return $object->isAbandoned();
|
||||
}
|
||||
|
|
|
@ -26,6 +26,24 @@ final class DifferentialRevisionAcceptTransaction
|
|||
return 500;
|
||||
}
|
||||
|
||||
public function getCommandKeyword() {
|
||||
$accept_key = 'differential.enable-email-accept';
|
||||
$allow_email_accept = PhabricatorEnv::getEnvConfig($accept_key);
|
||||
if (!$allow_email_accept) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return 'accept';
|
||||
}
|
||||
|
||||
public function getCommandAliases() {
|
||||
return array();
|
||||
}
|
||||
|
||||
public function getCommandSummary() {
|
||||
return pht('Accept a revision.');
|
||||
}
|
||||
|
||||
public function generateOldValue($object) {
|
||||
$actor = $this->getActor();
|
||||
return $this->isViewerAcceptingReviewer($object, $actor);
|
||||
|
|
|
@ -19,6 +19,18 @@ abstract class DifferentialRevisionActionTransaction
|
|||
abstract protected function validateAction($object, PhabricatorUser $viewer);
|
||||
abstract protected function getRevisionActionLabel();
|
||||
|
||||
public function getCommandKeyword() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getCommandAliases() {
|
||||
return array();
|
||||
}
|
||||
|
||||
public function getCommandSummary() {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected function getRevisionActionOrder() {
|
||||
return 1000;
|
||||
}
|
||||
|
|
|
@ -26,6 +26,20 @@ final class DifferentialRevisionCommandeerTransaction
|
|||
return 700;
|
||||
}
|
||||
|
||||
public function getCommandKeyword() {
|
||||
return 'commandeer';
|
||||
}
|
||||
|
||||
public function getCommandAliases() {
|
||||
return array(
|
||||
'claim',
|
||||
);
|
||||
}
|
||||
|
||||
public function getCommandSummary() {
|
||||
return pht('Commadeer a revision.');
|
||||
}
|
||||
|
||||
public function generateOldValue($object) {
|
||||
return $object->getAuthorPHID();
|
||||
}
|
||||
|
|
|
@ -27,6 +27,20 @@ final class DifferentialRevisionPlanChangesTransaction
|
|||
return 200;
|
||||
}
|
||||
|
||||
public function getCommandKeyword() {
|
||||
return 'planchanges';
|
||||
}
|
||||
|
||||
public function getCommandAliases() {
|
||||
return array(
|
||||
'rethink',
|
||||
);
|
||||
}
|
||||
|
||||
public function getCommandSummary() {
|
||||
return pht('Plan changes to a revision.');
|
||||
}
|
||||
|
||||
public function generateOldValue($object) {
|
||||
$status_planned = ArcanistDifferentialRevisionStatus::CHANGES_PLANNED;
|
||||
return ($object->getStatus() == $status_planned);
|
||||
|
|
|
@ -26,6 +26,18 @@ final class DifferentialRevisionReclaimTransaction
|
|||
return 600;
|
||||
}
|
||||
|
||||
public function getCommandKeyword() {
|
||||
return 'reclaim';
|
||||
}
|
||||
|
||||
public function getCommandAliases() {
|
||||
return array();
|
||||
}
|
||||
|
||||
public function getCommandSummary() {
|
||||
return pht('Reclaim a revision.');
|
||||
}
|
||||
|
||||
public function generateOldValue($object) {
|
||||
return !$object->isAbandoned();
|
||||
}
|
||||
|
|
|
@ -26,6 +26,20 @@ final class DifferentialRevisionRejectTransaction
|
|||
return 600;
|
||||
}
|
||||
|
||||
public function getCommandKeyword() {
|
||||
return 'request';
|
||||
}
|
||||
|
||||
public function getCommandAliases() {
|
||||
return array(
|
||||
'reject',
|
||||
);
|
||||
}
|
||||
|
||||
public function getCommandSummary() {
|
||||
return pht('Request changes to a revision.');
|
||||
}
|
||||
|
||||
public function generateOldValue($object) {
|
||||
$actor = $this->getActor();
|
||||
return $this->isViewerRejectingReviewer($object, $actor);
|
||||
|
|
|
@ -26,6 +26,18 @@ final class DifferentialRevisionResignTransaction
|
|||
return 700;
|
||||
}
|
||||
|
||||
public function getCommandKeyword() {
|
||||
return 'resign';
|
||||
}
|
||||
|
||||
public function getCommandAliases() {
|
||||
return array();
|
||||
}
|
||||
|
||||
public function getCommandSummary() {
|
||||
return pht('Resign from a revision.');
|
||||
}
|
||||
|
||||
public function generateOldValue($object) {
|
||||
$actor = $this->getActor();
|
||||
return !$this->isViewerAnyReviewer($object, $actor);
|
||||
|
|
Loading…
Reference in a new issue