From be1fbba69858555500499f316cfd075795e1ca8e Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 1 Apr 2015 09:45:18 -0700 Subject: [PATCH] Implement a "!subscribe" mail command Summary: Ref T7199. Implements "!subscribe". Test Plan: Used `bin/mail receive-test` to apply the command to objects. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T7199 Differential Revision: https://secure.phabricator.com/D12247 --- src/__phutil_library_map__.php | 2 + ...atorSubscriptionsSubscribeEmailCommand.php | 74 +++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 src/applications/subscriptions/command/PhabricatorSubscriptionsSubscribeEmailCommand.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index f924623cb0..4a3f7ef95d 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -2550,6 +2550,7 @@ phutil_register_library_map(array( 'PhabricatorSubscriptionsEditController' => 'applications/subscriptions/controller/PhabricatorSubscriptionsEditController.php', 'PhabricatorSubscriptionsEditor' => 'applications/subscriptions/editor/PhabricatorSubscriptionsEditor.php', 'PhabricatorSubscriptionsListController' => 'applications/subscriptions/controller/PhabricatorSubscriptionsListController.php', + 'PhabricatorSubscriptionsSubscribeEmailCommand' => 'applications/subscriptions/command/PhabricatorSubscriptionsSubscribeEmailCommand.php', 'PhabricatorSubscriptionsTransactionController' => 'applications/subscriptions/controller/PhabricatorSubscriptionsTransactionController.php', 'PhabricatorSubscriptionsUIEventListener' => 'applications/subscriptions/events/PhabricatorSubscriptionsUIEventListener.php', 'PhabricatorSubscriptionsUnsubscribeEmailCommand' => 'applications/subscriptions/command/PhabricatorSubscriptionsUnsubscribeEmailCommand.php', @@ -5937,6 +5938,7 @@ phutil_register_library_map(array( 'PhabricatorSubscriptionsEditController' => 'PhabricatorController', 'PhabricatorSubscriptionsEditor' => 'PhabricatorEditor', 'PhabricatorSubscriptionsListController' => 'PhabricatorController', + 'PhabricatorSubscriptionsSubscribeEmailCommand' => 'MetaMTAEmailTransactionCommand', 'PhabricatorSubscriptionsTransactionController' => 'PhabricatorController', 'PhabricatorSubscriptionsUIEventListener' => 'PhabricatorEventListener', 'PhabricatorSubscriptionsUnsubscribeEmailCommand' => 'MetaMTAEmailTransactionCommand', diff --git a/src/applications/subscriptions/command/PhabricatorSubscriptionsSubscribeEmailCommand.php b/src/applications/subscriptions/command/PhabricatorSubscriptionsSubscribeEmailCommand.php new file mode 100644 index 0000000000..a20da47c4e --- /dev/null +++ b/src/applications/subscriptions/command/PhabricatorSubscriptionsSubscribeEmailCommand.php @@ -0,0 +1,74 @@ +setViewer($viewer) + ->setAllowedTypes( + array( + PhabricatorPeopleUserPHIDType::TYPECONST, + PhabricatorProjectProjectPHIDType::TYPECONST, + )) + ->setObjectList(implode(' ', $argv)) + ->setAllowPartialResults(true) + ->execute(); + + $xactions = array(); + + $xactions[] = $object->getApplicationTransactionTemplate() + ->setTransactionType(PhabricatorTransactions::TYPE_SUBSCRIBERS) + ->setNewValue( + array( + '+' => array_fuse($subscriber_phids), + )); + + return $xactions; + } + +}