From f54bc8ae58d39f227d081b15f58faa84a9c7a15d Mon Sep 17 00:00:00 2001 From: epriestley Date: Fri, 14 Mar 2014 11:52:31 -0700 Subject: [PATCH] Add "Send an email" action to Herald for Maniphest Summary: Fixes T4403. Supports the "send an email" action in Maniphest. Test Plan: Wrote a "email duck" rule, then commented on a task and saw "duck" get an email. Reviewers: btrahan Reviewed By: btrahan Subscribers: aran, epriestley Maniphest Tasks: T4403 Differential Revision: https://secure.phabricator.com/D8529 --- .../adapter/HeraldManiphestTaskAdapter.php | 21 +++++++++++++++---- .../herald/storage/HeraldRule.php | 2 +- .../editor/ManiphestTransactionEditor.php | 16 +++++++++++++- 3 files changed, 33 insertions(+), 6 deletions(-) diff --git a/src/applications/herald/adapter/HeraldManiphestTaskAdapter.php b/src/applications/herald/adapter/HeraldManiphestTaskAdapter.php index d4cbfcab2f..38153e7442 100644 --- a/src/applications/herald/adapter/HeraldManiphestTaskAdapter.php +++ b/src/applications/herald/adapter/HeraldManiphestTaskAdapter.php @@ -1,14 +1,16 @@ emailPHIDs; + } public function getAdapterApplicationClass() { return 'PhabricatorApplicationManiphest'; @@ -98,6 +100,7 @@ final class HeraldManiphestTaskAdapter extends HeraldAdapter { case HeraldRuleTypeConfig::RULE_TYPE_GLOBAL: return array( self::ACTION_ADD_CC, + self::ACTION_EMAIL, self::ACTION_ASSIGN_TASK, self::ACTION_ADD_PROJECTS, self::ACTION_NOTHING, @@ -105,6 +108,7 @@ final class HeraldManiphestTaskAdapter extends HeraldAdapter { case HeraldRuleTypeConfig::RULE_TYPE_PERSONAL: return array( self::ACTION_ADD_CC, + self::ACTION_EMAIL, self::ACTION_FLAG, self::ACTION_ASSIGN_TASK, self::ACTION_NOTHING, @@ -161,7 +165,16 @@ final class HeraldManiphestTaskAdapter extends HeraldAdapter { $result[] = new HeraldApplyTranscript( $effect, true, - pht('Added address to cc list.')); + pht('Added addresses to cc list.')); + break; + case self::ACTION_EMAIL: + foreach ($effect->getTarget() as $phid) { + $this->emailPHIDs[] = $phid; + } + $result[] = new HeraldApplyTranscript( + $effect, + true, + pht('Added addresses to email list.')); break; case self::ACTION_FLAG: $result[] = parent::applyFlagEffect( diff --git a/src/applications/herald/storage/HeraldRule.php b/src/applications/herald/storage/HeraldRule.php index 34ead08f62..a911bbc4a0 100644 --- a/src/applications/herald/storage/HeraldRule.php +++ b/src/applications/herald/storage/HeraldRule.php @@ -17,7 +17,7 @@ final class HeraldRule extends HeraldDAO protected $isDisabled = 0; protected $triggerObjectPHID; - protected $configVersion = 33; + protected $configVersion = 34; // phids for which this rule has been applied private $ruleApplied = self::ATTACHABLE; diff --git a/src/applications/maniphest/editor/ManiphestTransactionEditor.php b/src/applications/maniphest/editor/ManiphestTransactionEditor.php index 90489b7077..4e8675c261 100644 --- a/src/applications/maniphest/editor/ManiphestTransactionEditor.php +++ b/src/applications/maniphest/editor/ManiphestTransactionEditor.php @@ -3,6 +3,8 @@ final class ManiphestTransactionEditor extends PhabricatorApplicationTransactionEditor { + private $heraldEmailPHIDs = array(); + public function getTransactionTypes() { $types = parent::getTransactionTypes(); @@ -271,7 +273,17 @@ final class ManiphestTransactionEditor } protected function getMailCC(PhabricatorLiskDAO $object) { - return $object->getCCPHIDs(); + $phids = array(); + + foreach ($object->getCCPHIDs() as $phid) { + $phids[] = $phid; + } + + foreach ($this->heraldEmailPHIDs as $phid) { + $phids[] = $phid; + } + + return $phids; } protected function buildReplyHandler(PhabricatorLiskDAO $object) { @@ -361,6 +373,8 @@ final class ManiphestTransactionEditor $object->save(); } + $this->heraldEmailPHIDs = $adapter->getEmailPHIDs(); + $xactions = array(); $assign_phid = $adapter->getAssignPHID();