From eca49cb91f7f9514803c62f8ee4c9293d7b426db Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 20 Mar 2013 15:50:02 -0700 Subject: [PATCH] Exclusion of actor as a mail recipient per preference can be overridden Summary: Fixes T2797 Currently, emails are sent in no case to the actor if he has disabled the preference to send emails for his own actions. This won't let us send any test emails from the MetaMTA application to ourselves. This revision corrects the latter by specifically overriding the option for test emails. Test Plan: tried to send emails to myself. verified test mail got blocked with change not applied. applied the change. verified new change with both preference enabled and disabled did work fine. Reviewers: epriestley Reviewed By: epriestley CC: kai, aran, Korvin Maniphest Tasks: T2797 Differential Revision: https://secure.phabricator.com/D5398 --- .../controller/PhabricatorMetaMTASendController.php | 1 + .../metamta/storage/PhabricatorMetaMTAMail.php | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/applications/metamta/controller/PhabricatorMetaMTASendController.php b/src/applications/metamta/controller/PhabricatorMetaMTASendController.php index a4e2be0e0f..2008b0ffe3 100644 --- a/src/applications/metamta/controller/PhabricatorMetaMTASendController.php +++ b/src/applications/metamta/controller/PhabricatorMetaMTASendController.php @@ -32,6 +32,7 @@ final class PhabricatorMetaMTASendController $mail->setIsHTML($request->getInt('html')); $mail->setIsBulk($request->getInt('bulk')); $mail->setMailTags($request->getStrList('mailtags')); + $mail->setOverrideNoSelfMailPreference(true); $mail->save(); if ($request->getInt('immediately')) { $mail->sendNow(); diff --git a/src/applications/metamta/storage/PhabricatorMetaMTAMail.php b/src/applications/metamta/storage/PhabricatorMetaMTAMail.php index 6f7db76d1d..7289a4132e 100644 --- a/src/applications/metamta/storage/PhabricatorMetaMTAMail.php +++ b/src/applications/metamta/storage/PhabricatorMetaMTAMail.php @@ -23,6 +23,7 @@ final class PhabricatorMetaMTAMail extends PhabricatorMetaMTADAO { protected $relatedPHID; private $excludePHIDs = array(); + private $overrideNoSelfMail = false; public function __construct() { @@ -115,6 +116,15 @@ final class PhabricatorMetaMTAMail extends PhabricatorMetaMTADAO { return $this->excludePHIDs; } + public function getOverrideNoSelfMailPreference() { + return $this->overrideNoSelfMail; + } + + public function setOverrideNoSelfMailPreference($override) { + $this->overrideNoSelfMail = $override; + return $this; + } + public function getTranslation(array $objects) { $default_translation = PhabricatorEnv::getEnvConfig('translation.provider'); $return = null; @@ -822,7 +832,7 @@ final class PhabricatorMetaMTAMail extends PhabricatorMetaMTADAO { $from_user = id(new PhabricatorUser())->loadOneWhere( 'phid = %s', $from); - if ($from_user) { + if ($from_user && !$this->getOverrideNoSelfMailPreference()) { $pref_key = PhabricatorUserPreferences::PREFERENCE_NO_SELF_MAIL; $exclude_self = $from_user ->loadPreferences()