Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / subscriptions / command / PhabricatorSubscriptionsSubscribeEmailCommand.php
blob0c361ad2c6728d9eb3be6fed92754915879c20f3
1 <?php
3 final class PhabricatorSubscriptionsSubscribeEmailCommand
4 extends MetaMTAEmailTransactionCommand {
6 public function getCommand() {
7 return 'subscribe';
10 public function getCommandSyntax() {
11 return '**!subscribe** //username #project ...//';
14 public function getCommandSummary() {
15 return pht('Add users or projects as subscribers.');
18 public function getCommandDescription() {
19 return pht(
20 'Add one or more subscribers to the object. You can add users by '.
21 'providing their usernames, or add projects by adding their hashtags. '.
22 'For example, use `%s` to add the user `alincoln` and the project with '.
23 'hashtag `#ios` as subscribers.'.
24 "\n\n".
25 'Subscribers which are invalid or unrecognized will be ignored. This '.
26 'command has no effect if you do not specify any subscribers.'.
27 "\n\n".
28 'Users who are CC\'d on the email itself are also automatically '.
29 'subscribed if Phabricator knows which accounts are linked to their '.
30 'email addresses.',
31 '!subscribe alincoln #ios');
34 public function getCommandAliases() {
35 return array(
36 'cc',
40 public function isCommandSupportedForObject(
41 PhabricatorApplicationTransactionInterface $object) {
42 return ($object instanceof PhabricatorSubscribableInterface);
45 public function buildTransactions(
46 PhabricatorUser $viewer,
47 PhabricatorApplicationTransactionInterface $object,
48 PhabricatorMetaMTAReceivedMail $mail,
49 $command,
50 array $argv) {
52 $subscriber_phids = id(new PhabricatorObjectListQuery())
53 ->setViewer($viewer)
54 ->setAllowedTypes(
55 array(
56 PhabricatorPeopleUserPHIDType::TYPECONST,
57 PhabricatorProjectProjectPHIDType::TYPECONST,
59 ->setObjectList(implode(' ', $argv))
60 ->setAllowPartialResults(true)
61 ->execute();
63 $xactions = array();
65 $xactions[] = $object->getApplicationTransactionTemplate()
66 ->setTransactionType(PhabricatorTransactions::TYPE_SUBSCRIBERS)
67 ->setNewValue(
68 array(
69 '+' => array_fuse($subscriber_phids),
70 ));
72 return $xactions;