@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<?php
2
3final class PhabricatorSubscriptionsSubscribeEmailCommand
4 extends MetaMTAEmailTransactionCommand {
5
6 public function getCommand() {
7 return 'subscribe';
8 }
9
10 public function getCommandSyntax() {
11 return '**!subscribe** //username #project ...//';
12 }
13
14 public function getCommandSummary() {
15 return pht('Add users or projects as subscribers.');
16 }
17
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 their addresses are associated with a known account.',
30 '!subscribe alincoln #ios');
31 }
32
33 public function getCommandAliases() {
34 return array(
35 'cc',
36 );
37 }
38
39 public function isCommandSupportedForObject(
40 PhabricatorApplicationTransactionInterface $object) {
41 return ($object instanceof PhabricatorSubscribableInterface);
42 }
43
44 public function buildTransactions(
45 PhabricatorUser $viewer,
46 PhabricatorApplicationTransactionInterface $object,
47 PhabricatorMetaMTAReceivedMail $mail,
48 $command,
49 array $argv) {
50
51 $subscriber_phids = id(new PhabricatorObjectListQuery())
52 ->setViewer($viewer)
53 ->setAllowedTypes(
54 array(
55 PhabricatorPeopleUserPHIDType::TYPECONST,
56 PhabricatorProjectProjectPHIDType::TYPECONST,
57 ))
58 ->setObjectList(implode(' ', $argv))
59 ->setAllowPartialResults(true)
60 ->execute();
61
62 $xactions = array();
63
64 $xactions[] = $object->getApplicationTransactionTemplate()
65 ->setTransactionType(PhabricatorTransactions::TYPE_SUBSCRIBERS)
66 ->setNewValue(
67 array(
68 '+' => array_fuse($subscriber_phids),
69 ));
70
71 return $xactions;
72 }
73
74}