diff --git a/src/applications/differential/editor/DifferentialTransactionEditor.php b/src/applications/differential/editor/DifferentialTransactionEditor.php --- a/src/applications/differential/editor/DifferentialTransactionEditor.php +++ b/src/applications/differential/editor/DifferentialTransactionEditor.php @@ -1731,8 +1731,7 @@ } // Save extra email PHIDs for later. - $email_phids = $adapter->getEmailPHIDsAddedByHerald(); - $this->heraldEmailPHIDs = array_keys($email_phids); + $this->heraldEmailPHIDs = $adapter->getEmailPHIDs(); // Apply build plans. HarbormasterBuildable::applyBuildPlans( diff --git a/src/applications/diffusion/herald/HeraldPreCommitAdapter.php b/src/applications/diffusion/herald/HeraldPreCommitAdapter.php --- a/src/applications/diffusion/herald/HeraldPreCommitAdapter.php +++ b/src/applications/diffusion/herald/HeraldPreCommitAdapter.php @@ -4,7 +4,6 @@ private $log; private $hookEngine; - private $emailPHIDs = array(); public function setPushLog(PhabricatorRepositoryPushLog $log) { $this->log = $log; @@ -28,10 +27,6 @@ return $this->log; } - public function getEmailPHIDs() { - return array_values($this->emailPHIDs); - } - public function supportsRuleType($rule_type) { switch ($rule_type) { case HeraldRuleTypeConfig::RULE_TYPE_GLOBAL: @@ -107,13 +102,7 @@ pht('Did nothing.')); break; case self::ACTION_EMAIL: - foreach ($effect->getTarget() as $phid) { - $this->emailPHIDs[$phid] = $phid; - } - $result[] = new HeraldApplyTranscript( - $effect, - true, - pht('Added mailable to mail targets.')); + $result[] = $this->applyEmailEffect($effect); break; case self::ACTION_BLOCK: $result[] = new HeraldApplyTranscript( diff --git a/src/applications/herald/adapter/HeraldAdapter.php b/src/applications/herald/adapter/HeraldAdapter.php --- a/src/applications/herald/adapter/HeraldAdapter.php +++ b/src/applications/herald/adapter/HeraldAdapter.php @@ -109,6 +109,11 @@ private $customFields = false; private $customActions = null; private $queuedTransactions = array(); + private $emailPHIDs = array(); + + public function getEmailPHIDs() { + return array_values($this->emailPHIDs); + } public function getCustomActions() { if ($this->customActions === null) { @@ -1032,6 +1037,18 @@ pht('Added flag.')); } + protected function applyEmailEffect(HeraldEffect $effect) { + + foreach ($effect->getTarget() as $phid) { + $this->emailPHIDs[$phid] = $phid; + } + + return new HeraldApplyTranscript( + $effect, + true, + pht('Added mailable to mail targets.')); + } + public static function getAllAdapters() { static $adapters; if (!$adapters) { diff --git a/src/applications/herald/adapter/HeraldCommitAdapter.php b/src/applications/herald/adapter/HeraldCommitAdapter.php --- a/src/applications/herald/adapter/HeraldCommitAdapter.php +++ b/src/applications/herald/adapter/HeraldCommitAdapter.php @@ -13,7 +13,6 @@ protected $commitData; private $commitDiff; - protected $emailPHIDs = array(); protected $addCCPHIDs = array(); protected $auditMap = array(); protected $buildPlans = array(); @@ -217,10 +216,6 @@ return $this->commit->getPHID(); } - public function getEmailPHIDs() { - return array_keys($this->emailPHIDs); - } - public function getAddCCMap() { return $this->addCCPHIDs; } @@ -499,13 +494,7 @@ pht('Great success at doing nothing.')); break; case self::ACTION_EMAIL: - foreach ($effect->getTarget() as $phid) { - $this->emailPHIDs[$phid] = true; - } - $result[] = new HeraldApplyTranscript( - $effect, - true, - pht('Added address to email targets.')); + $result[] = $this->applyEmailEffect($effect); break; case self::ACTION_ADD_CC: foreach ($effect->getTarget() as $phid) { diff --git a/src/applications/herald/adapter/HeraldDifferentialRevisionAdapter.php b/src/applications/herald/adapter/HeraldDifferentialRevisionAdapter.php --- a/src/applications/herald/adapter/HeraldDifferentialRevisionAdapter.php +++ b/src/applications/herald/adapter/HeraldDifferentialRevisionAdapter.php @@ -11,7 +11,6 @@ protected $newCCs = array(); protected $remCCs = array(); - protected $emailPHIDs = array(); protected $addReviewerPHIDs = array(); protected $blockingReviewerPHIDs = array(); protected $buildPlans = array(); @@ -131,10 +130,6 @@ return $this->remCCs; } - public function getEmailPHIDsAddedByHerald() { - return $this->emailPHIDs; - } - public function getReviewersAddedByHerald() { return $this->addReviewerPHIDs; } @@ -333,8 +328,9 @@ $this->revision->getPHID()); break; case self::ACTION_EMAIL: + $result[] = $this->applyEmailEffect($effect); + break; case self::ACTION_ADD_CC: - $op = ($action == self::ACTION_EMAIL) ? 'email' : 'CC'; $base_target = $effect->getTarget(); $forbidden = array(); foreach ($base_target as $key => $fbid) { @@ -342,11 +338,7 @@ $forbidden[] = $fbid; unset($base_target[$key]); } else { - if ($action == self::ACTION_EMAIL) { - $this->emailPHIDs[$fbid] = true; - } else { - $this->newCCs[$fbid] = true; - } + $this->newCCs[$fbid] = true; } } @@ -358,18 +350,18 @@ $result[] = new HeraldApplyTranscript( $effect, true, - pht('Added these addresses to %s list. '. - 'Others could not be added.', $op)); + pht('Added these addresses to CC list. '. + 'Others could not be added.')); } $result[] = new HeraldApplyTranscript( $failed, false, - pht('%s forbidden, these addresses have unsubscribed.', $op)); + pht('CC forbidden, these addresses have unsubscribed.')); } else { $result[] = new HeraldApplyTranscript( $effect, true, - pht('Added addresses to %s list.', $op)); + pht('Added addresses to CC list.')); } break; case self::ACTION_REMOVE_CC: diff --git a/src/applications/herald/adapter/HeraldManiphestTaskAdapter.php b/src/applications/herald/adapter/HeraldManiphestTaskAdapter.php --- a/src/applications/herald/adapter/HeraldManiphestTaskAdapter.php +++ b/src/applications/herald/adapter/HeraldManiphestTaskAdapter.php @@ -6,11 +6,6 @@ private $ccPHIDs = array(); private $assignPHID; private $projectPHIDs = array(); - private $emailPHIDs = array(); - - public function getEmailPHIDs() { - return $this->emailPHIDs; - } public function getAdapterApplicationClass() { return 'PhabricatorManiphestApplication'; @@ -178,13 +173,7 @@ 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.')); + $result[] = $this->applyEmailEffect($effect); break; case self::ACTION_FLAG: $result[] = parent::applyFlagEffect( diff --git a/src/applications/phriction/herald/PhrictionDocumentHeraldAdapter.php b/src/applications/phriction/herald/PhrictionDocumentHeraldAdapter.php --- a/src/applications/phriction/herald/PhrictionDocumentHeraldAdapter.php +++ b/src/applications/phriction/herald/PhrictionDocumentHeraldAdapter.php @@ -4,7 +4,6 @@ private $document; private $ccPHIDs = array(); - private $emailPHIDs = array(); public function getAdapterApplicationClass() { return 'PhabricatorPhrictionApplication'; @@ -30,15 +29,11 @@ $this->ccPHIDs = $cc_phids; return $this; } + public function getCcPHIDs() { return $this->ccPHIDs; } - public function getEmailPHIDs() { - return $this->emailPHIDs; - } - - public function getAdapterContentName() { return pht('Phriction Documents'); } @@ -143,13 +138,7 @@ $this->getDocument()->getPHID()); break; case self::ACTION_EMAIL: - foreach ($effect->getTarget() as $phid) { - $this->emailPHIDs[] = $phid; - } - $result[] = new HeraldApplyTranscript( - $effect, - true, - pht('Added addresses to email list.')); + $result[] = $this->applyEmailEffect($effect); break; default: $custom_result = parent::handleCustomHeraldEffect($effect);