forked from phacility/phabricator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDifferentialActionEmailCommand.php
140 lines (111 loc) · 3.57 KB
/
DifferentialActionEmailCommand.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<?php
final class DifferentialActionEmailCommand
extends MetaMTAEmailTransactionCommand {
private $command;
private $action;
private $aliases;
private $commandSummary;
private $commandDescription;
public function getCommand() {
return $this->command;
}
private function setCommand($command) {
$this->command = $command;
return $this;
}
private function setAction($action) {
$this->action = $action;
return $this;
}
private function getAction() {
return $this->action;
}
private function setCommandAliases(array $aliases) {
$this->aliases = $aliases;
return $this;
}
public function getCommandAliases() {
return $this->aliases;
}
public function setCommandSummary($command_summary) {
$this->commandSummary = $command_summary;
return $this;
}
public function getCommandSummary() {
return $this->commandSummary;
}
public function setCommandDescription($command_description) {
$this->commandDescription = $command_description;
return $this;
}
public function getCommandDescription() {
return $this->commandDescription;
}
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(
);
$objects = array();
foreach ($actions as $action => $keyword) {
$object = id(new DifferentialActionEmailCommand())
->setCommand($keyword)
->setAction($action)
->setCommandSummary($summaries[$action]);
if (isset($aliases[$action])) {
$object->setCommandAliases($aliases[$action]);
}
if (isset($descriptions[$action])) {
$object->setCommandDescription($descriptions[$action]);
}
$objects[] = $object;
}
return $objects;
}
public function isCommandSupportedForObject(
PhabricatorApplicationTransactionInterface $object) {
return ($object instanceof DifferentialRevision);
}
public function buildTransactions(
PhabricatorUser $viewer,
PhabricatorApplicationTransactionInterface $object,
PhabricatorMetaMTAReceivedMail $mail,
$command,
array $argv) {
$xactions = array();
$xactions[] = $object->getApplicationTransactionTemplate()
->setTransactionType(DifferentialTransaction::TYPE_ACTION)
->setNewValue($this->getAction());
return $xactions;
}
}