From 500506bfef2807675f19f22cd9efb9e7d71087a7 Mon Sep 17 00:00:00 2001 From: epriestley Date: Tue, 12 Aug 2014 12:28:07 -0700 Subject: [PATCH] Persist excluded recipients when saving mail Summary: Fixes T5185. The fundamental issue is that this `excludePHIDs` property was not saved, so the logic went like this: - Generate `excludePHIDs` correctly. - Pass `excludePHIDs` through the stack. - Perform some other computations correctly. - Queue the mail for the daemons, throwing it away. {icon bomb} - Daemons process mail with empty `excludePHIDs` list. Store it in the persistent properties array instead. Also remove the "override self mail" thing, since it's only used by `bin/mail send-test` and suffers from the same issue. I think it's too useless to fix, since even if you get caught by it, `bin/mail` makes it clear why the message was dropped. Test Plan: Notable: - `exclude` present in properties - Exclusion reason under RECIPIENTS header {P1229} Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T5185 Differential Revision: https://secure.phabricator.com/D10234 --- ...bricatorMailManagementSendTestWorkflow.php | 1 - .../storage/PhabricatorMetaMTAMail.php | 20 +++++-------------- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/src/applications/metamta/management/PhabricatorMailManagementSendTestWorkflow.php b/src/applications/metamta/management/PhabricatorMailManagementSendTestWorkflow.php index 763e0d764a..61b227a05b 100644 --- a/src/applications/metamta/management/PhabricatorMailManagementSendTestWorkflow.php +++ b/src/applications/metamta/management/PhabricatorMailManagementSendTestWorkflow.php @@ -117,7 +117,6 @@ final class PhabricatorMailManagementSendTestWorkflow ->addCCs($ccs) ->setSubject($subject) ->setBody($body) - ->setOverrideNoSelfMailPreference(true) ->setIsHTML($is_html) ->setIsBulk($is_bulk) ->setMailTags($tags); diff --git a/src/applications/metamta/storage/PhabricatorMetaMTAMail.php b/src/applications/metamta/storage/PhabricatorMetaMTAMail.php index e583e508b5..75ee634b86 100644 --- a/src/applications/metamta/storage/PhabricatorMetaMTAMail.php +++ b/src/applications/metamta/storage/PhabricatorMetaMTAMail.php @@ -17,8 +17,6 @@ final class PhabricatorMetaMTAMail extends PhabricatorMetaMTADAO { protected $message; protected $relatedPHID; - private $excludePHIDs = array(); - private $overrideNoSelfMail = false; private $recipientExpansionMap; public function __construct() { @@ -115,21 +113,13 @@ final class PhabricatorMetaMTAMail extends PhabricatorMetaMTADAO { return $this; } - public function setExcludeMailRecipientPHIDs($exclude) { - $this->excludePHIDs = $exclude; + public function setExcludeMailRecipientPHIDs(array $exclude) { + $this->setParam('exclude', $exclude); return $this; } + private function getExcludeMailRecipientPHIDs() { - return $this->excludePHIDs; - } - - public function getOverrideNoSelfMailPreference() { - return $this->overrideNoSelfMail; - } - - public function setOverrideNoSelfMailPreference($override) { - $this->overrideNoSelfMail = $override; - return $this; + return $this->getParam('exclude', array()); } public function getTranslation(array $objects) { @@ -828,7 +818,7 @@ final class PhabricatorMetaMTAMail extends PhabricatorMetaMTADAO { ->withPHIDs(array($from_phid)) ->execute(); $from_user = head($from_user); - if ($from_user && !$this->getOverrideNoSelfMailPreference()) { + if ($from_user) { $pref_key = PhabricatorUserPreferences::PREFERENCE_NO_SELF_MAIL; $exclude_self = $from_user ->loadPreferences()