From de01f3e2e08e7c8b1e492ef4203541fe2d503a9d Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 9 Sep 2015 14:07:07 -0700 Subject: [PATCH] Add Maniphest Task email creator to CCs Summary: Fixes T9369. Test Plan: - Sent a mail with Mail.app to `bugs@local.phacility.com`. - Used "View Raw Mail", copy-pasted it into `mail.txt` on disk. - Ran `cat mail.txt | ./scripts/mail/manage_mail.php --process-duplicates`. - Saw task get created and me get added as CC. - Changed "To" to include another user, ran command again, saw task get created and other user get added as CC. Reviewers: chad Reviewed By: chad Subscribers: Korvin Maniphest Tasks: T9369 Differential Revision: https://secure.phabricator.com/D14086 --- .../mail/ConpherenceCreateThreadMailReceiver.php | 2 +- .../mail/ManiphestCreateMailReceiver.php | 2 +- .../maniphest/mail/ManiphestReplyHandler.php | 15 +++++++++++++-- .../receiver/PhabricatorObjectMailReceiver.php | 2 +- .../storage/PhabricatorMetaMTAReceivedMail.php | 2 +- ...bricatorApplicationTransactionReplyHandler.php | 8 ++++---- 6 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/applications/conpherence/mail/ConpherenceCreateThreadMailReceiver.php b/src/applications/conpherence/mail/ConpherenceCreateThreadMailReceiver.php index aacf4426d4..543233df6e 100644 --- a/src/applications/conpherence/mail/ConpherenceCreateThreadMailReceiver.php +++ b/src/applications/conpherence/mail/ConpherenceCreateThreadMailReceiver.php @@ -56,7 +56,7 @@ final class ConpherenceCreateThreadMailReceiver ->setMailReceiver(ConpherenceThread::initializeNewRoom($sender)) ->setMailAddedParticipantPHIDs($phids) ->setActor($sender) - ->setExcludeMailRecipientPHIDs($mail->loadExcludeMailRecipientPHIDs()) + ->setExcludeMailRecipientPHIDs($mail->loadAllRecipientPHIDs()) ->processEmail($mail); if ($conpherence) { diff --git a/src/applications/maniphest/mail/ManiphestCreateMailReceiver.php b/src/applications/maniphest/mail/ManiphestCreateMailReceiver.php index 0102b1bd7b..767a11d267 100644 --- a/src/applications/maniphest/mail/ManiphestCreateMailReceiver.php +++ b/src/applications/maniphest/mail/ManiphestCreateMailReceiver.php @@ -24,7 +24,7 @@ final class ManiphestCreateMailReceiver extends PhabricatorMailReceiver { $handler->setActor($sender); $handler->setExcludeMailRecipientPHIDs( - $mail->loadExcludeMailRecipientPHIDs()); + $mail->loadAllRecipientPHIDs()); if ($this->getApplicationEmail()) { $handler->setApplicationEmail($this->getApplicationEmail()); } diff --git a/src/applications/maniphest/mail/ManiphestReplyHandler.php b/src/applications/maniphest/mail/ManiphestReplyHandler.php index af96de70da..bc9b2456d4 100644 --- a/src/applications/maniphest/mail/ManiphestReplyHandler.php +++ b/src/applications/maniphest/mail/ManiphestReplyHandler.php @@ -19,17 +19,28 @@ final class ManiphestReplyHandler $object = $this->getMailReceiver(); $is_new = !$object->getID(); + $actor = $this->getActor(); $xactions = array(); if ($is_new) { - $xactions[] = $object->getApplicationTransactionTemplate() + $xactions[] = $this->newTransaction() ->setTransactionType(ManiphestTransaction::TYPE_TITLE) ->setNewValue(nonempty($mail->getSubject(), pht('Untitled Task'))); - $xactions[] = $object->getApplicationTransactionTemplate() + $xactions[] = $this->newTransaction() ->setTransactionType(ManiphestTransaction::TYPE_DESCRIPTION) ->setNewValue($body); + + $actor_phid = $actor->getPHID(); + if ($actor_phid) { + $xactions[] = $this->newTransaction() + ->setTransactionType(PhabricatorTransactions::TYPE_SUBSCRIBERS) + ->setNewValue( + array( + '+' => array($actor_phid), + )); + } } return $xactions; diff --git a/src/applications/metamta/receiver/PhabricatorObjectMailReceiver.php b/src/applications/metamta/receiver/PhabricatorObjectMailReceiver.php index 062eb52502..81f8ade37b 100644 --- a/src/applications/metamta/receiver/PhabricatorObjectMailReceiver.php +++ b/src/applications/metamta/receiver/PhabricatorObjectMailReceiver.php @@ -49,7 +49,7 @@ abstract class PhabricatorObjectMailReceiver extends PhabricatorMailReceiver { return $handler ->setMailReceiver($object) ->setActor($sender) - ->setExcludeMailRecipientPHIDs($mail->loadExcludeMailRecipientPHIDs()) + ->setExcludeMailRecipientPHIDs($mail->loadAllRecipientPHIDs()) ->processEmail($mail); } diff --git a/src/applications/metamta/storage/PhabricatorMetaMTAReceivedMail.php b/src/applications/metamta/storage/PhabricatorMetaMTAReceivedMail.php index 60e8a5e468..f6c9474255 100644 --- a/src/applications/metamta/storage/PhabricatorMetaMTAReceivedMail.php +++ b/src/applications/metamta/storage/PhabricatorMetaMTAReceivedMail.php @@ -82,7 +82,7 @@ final class PhabricatorMetaMTAReceivedMail extends PhabricatorMetaMTADAO { return $this->getRawEmailAddresses(idx($this->headers, 'to')); } - public function loadExcludeMailRecipientPHIDs() { + public function loadAllRecipientPHIDs() { $addresses = array_merge( $this->getToAddresses(), $this->getCCAddresses()); diff --git a/src/applications/transactions/replyhandler/PhabricatorApplicationTransactionReplyHandler.php b/src/applications/transactions/replyhandler/PhabricatorApplicationTransactionReplyHandler.php index 82f3eca2cc..560a750f00 100644 --- a/src/applications/transactions/replyhandler/PhabricatorApplicationTransactionReplyHandler.php +++ b/src/applications/transactions/replyhandler/PhabricatorApplicationTransactionReplyHandler.php @@ -39,7 +39,7 @@ abstract class PhabricatorApplicationTransactionReplyHandler return $editor; } - private function newTransaction() { + protected function newTransaction() { return $this->getMailReceiver()->getApplicationTransactionTemplate(); } @@ -80,15 +80,15 @@ abstract class PhabricatorApplicationTransactionReplyHandler $xactions = $this->didReceiveMail($mail, $body); // If this object is subscribable, subscribe all the users who were - // CC'd on the message. + // recipients on the message. if ($object instanceof PhabricatorSubscribableInterface) { - $subscriber_phids = $mail->loadCCPHIDs(); + $subscriber_phids = $mail->loadAllRecipientPHIDs(); if ($subscriber_phids) { $xactions[] = $this->newTransaction() ->setTransactionType(PhabricatorTransactions::TYPE_SUBSCRIBERS) ->setNewValue( array( - '+' => array($viewer->getPHID()), + '+' => $subscriber_phids, )); } }