From 59db2826247cb2ecf8683fa31ab367a780d8583a Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 23 Jul 2012 09:23:54 -0700 Subject: [PATCH] Fix an issue with email "Re:" prefix Summary: See detailed discussion in T1543. Test Plan: - Enabled multiplexing. - Set user A to "enable Re". - Created a task owned by user B with user A cc'd. - Verified A got no "Re:" before this patch. - Applied patch. - Verified A got "Re:" after this patch. Reviewers: nh, btrahan, vrana Reviewed By: nh CC: aran Maniphest Tasks: T1543 Differential Revision: https://secure.phabricator.com/D3031 --- .../storage/PhabricatorMetaMTAMail.php | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/applications/metamta/storage/PhabricatorMetaMTAMail.php b/src/applications/metamta/storage/PhabricatorMetaMTAMail.php index 5dae327158..b78aa1e47b 100644 --- a/src/applications/metamta/storage/PhabricatorMetaMTAMail.php +++ b/src/applications/metamta/storage/PhabricatorMetaMTAMail.php @@ -448,12 +448,23 @@ final class PhabricatorMetaMTAMail extends PhabricatorMetaMTADAO { $prefs = null; if ($use_prefs) { - $to = idx($params, 'to', array()); - $user = id(new PhabricatorUser())->loadOneWhere( - 'phid = %s', - head($to)); - if ($user) { - $prefs = $user->loadPreferences(); + + // If multiplexing is enabled, some recipients will be in "Cc" + // rather than "To". We'll move them to "To" later (or supply a + // dummy "To") but need to look for the recipient in either the + // "To" or "Cc" fields here. + $target_phid = head(idx($params, 'to', array())); + if (!$target_phid) { + $target_phid = head(idx($params, 'cc', array())); + } + + if ($target_phid) { + $user = id(new PhabricatorUser())->loadOneWhere( + 'phid = %s', + $target_phid); + if ($user) { + $prefs = $user->loadPreferences(); + } } }