From ba9cd64e514eaf3204dd074e4b7fa8f8e2c7f037 Mon Sep 17 00:00:00 2001 From: epriestley Date: Fri, 11 Mar 2016 16:02:19 -0800 Subject: [PATCH] Stop moving "Cc" addresses to "To" when building mail targets Summary: Fixes T10539. When building mail targets, we fail to preserve whether a recipient was originally "To" or "Cc", and just move everyone to "To". Test Plan: Added a comment to a task with a "To" user and a "Cc" user, with `metamta.placeholder-to-recipient` set and `metamta.one-mail-per-recipient` set. Got mail with me Cc'd as the Cc'd user: {F1172020} Reviewers: chad Reviewed By: chad Maniphest Tasks: T10539 Differential Revision: https://secure.phabricator.com/D15465 --- .../replyhandler/PhabricatorMailReplyHandler.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/applications/metamta/replyhandler/PhabricatorMailReplyHandler.php b/src/applications/metamta/replyhandler/PhabricatorMailReplyHandler.php index efae153a0f..e4da2a04d6 100644 --- a/src/applications/metamta/replyhandler/PhabricatorMailReplyHandler.php +++ b/src/applications/metamta/replyhandler/PhabricatorMailReplyHandler.php @@ -254,10 +254,19 @@ abstract class PhabricatorMailReplyHandler extends Phobject { $map = $to + $cc; foreach ($map as $phid => $user) { + // Preserve the original To/Cc information on the target. + if (isset($to[$phid])) { + $target_to = array($phid => $user); + $target_cc = array(); + } else { + $target_to = array(); + $target_cc = array($phid => $user); + } + $target = id(clone $template) ->setViewer($user) - ->setToMap(array($phid => $user)) - ->setCCMap(array()); + ->setToMap($target_to) + ->setCCMap($target_cc); if ($supports_private_replies) { $reply_to = $this->getPrivateReplyHandlerEmailAddress($user);