From ba37594362420ea7c13d17d22b92dc77e39c467b Mon Sep 17 00:00:00 2001 From: Bob Trahan Date: Fri, 13 Sep 2013 15:08:17 -0700 Subject: [PATCH] Add support for more granular sending of email in application transactions Summary: Deploy on paste and macro for create stories, 'cuz those are boring emails. Fixes T3808. Test Plan: made a paste and a macro. commented on 'em. verified i got mail on comments only. Reviewers: epriestley Reviewed By: epriestley CC: Korvin, aran Maniphest Tasks: T3808 Differential Revision: https://secure.phabricator.com/D6988 --- .../conpherence/editor/ConpherenceEditor.php | 4 +++- .../files/editor/PhabricatorFileEditor.php | 4 +++- .../legalpad/editor/LegalpadDocumentEditor.php | 4 +++- .../macro/editor/PhabricatorMacroEditor.php | 12 +++++++++++- .../paste/editor/PhabricatorPasteEditor.php | 12 +++++++++++- src/applications/pholio/editor/PholioMockEditor.php | 4 +++- .../ponder/editor/PonderQuestionEditor.php | 4 +++- .../editor/ReleephRequestTransactionalEditor.php | 4 +++- .../PhabricatorApplicationTransactionEditor.php | 6 ++++-- 9 files changed, 44 insertions(+), 10 deletions(-) diff --git a/src/applications/conpherence/editor/ConpherenceEditor.php b/src/applications/conpherence/editor/ConpherenceEditor.php index e3f9924f2f..8c8737edaf 100644 --- a/src/applications/conpherence/editor/ConpherenceEditor.php +++ b/src/applications/conpherence/editor/ConpherenceEditor.php @@ -322,7 +322,9 @@ final class ConpherenceEditor extends PhabricatorApplicationTransactionEditor { return parent::mergeTransactions($u, $v); } - protected function supportsMail() { + protected function shouldSendMail( + PhabricatorLiskDAO $object, + array $xactions) { return true; } diff --git a/src/applications/files/editor/PhabricatorFileEditor.php b/src/applications/files/editor/PhabricatorFileEditor.php index d7c2709f79..7201322ffa 100644 --- a/src/applications/files/editor/PhabricatorFileEditor.php +++ b/src/applications/files/editor/PhabricatorFileEditor.php @@ -36,7 +36,9 @@ final class PhabricatorFileEditor PhabricatorApplicationTransaction $xaction) { } - protected function supportsMail() { + protected function shouldSendMail( + PhabricatorLiskDAO $object, + array $xactions) { return true; } diff --git a/src/applications/legalpad/editor/LegalpadDocumentEditor.php b/src/applications/legalpad/editor/LegalpadDocumentEditor.php index c8070a0b9e..fc86acf048 100644 --- a/src/applications/legalpad/editor/LegalpadDocumentEditor.php +++ b/src/applications/legalpad/editor/LegalpadDocumentEditor.php @@ -122,7 +122,9 @@ final class LegalpadDocumentEditor /* -( Sending Mail )------------------------------------------------------- */ - protected function supportsMail() { + protected function shouldSendMail( + PhabricatorLiskDAO $object, + array $xactions) { return true; } diff --git a/src/applications/macro/editor/PhabricatorMacroEditor.php b/src/applications/macro/editor/PhabricatorMacroEditor.php index 93d7af6d4e..9b706ad224 100644 --- a/src/applications/macro/editor/PhabricatorMacroEditor.php +++ b/src/applications/macro/editor/PhabricatorMacroEditor.php @@ -78,7 +78,17 @@ final class PhabricatorMacroEditor return parent::mergeTransactions($u, $v); } - protected function supportsMail() { + protected function shouldSendMail( + PhabricatorLiskDAO $object, + array $xactions) { + foreach ($xactions as $xaction) { + switch ($xaction->getTransactionType()) { + case PhabricatorMacroTransactionType::TYPE_NAME; + return ($xaction->getOldValue() !== null); + default: + break; + } + } return true; } diff --git a/src/applications/paste/editor/PhabricatorPasteEditor.php b/src/applications/paste/editor/PhabricatorPasteEditor.php index 88ef508664..20da125257 100644 --- a/src/applications/paste/editor/PhabricatorPasteEditor.php +++ b/src/applications/paste/editor/PhabricatorPasteEditor.php @@ -100,7 +100,17 @@ final class PhabricatorPasteEditor } } - protected function supportsMail() { + protected function shouldSendMail( + PhabricatorLiskDAO $object, + array $xactions) { + foreach ($xactions as $xaction) { + switch ($xaction->getTransactionType()) { + case PhabricatorPasteTransaction::TYPE_CREATE: + return false; + default: + break; + } + } return true; } diff --git a/src/applications/pholio/editor/PholioMockEditor.php b/src/applications/pholio/editor/PholioMockEditor.php index c82edd3d72..30e82b8fe2 100644 --- a/src/applications/pholio/editor/PholioMockEditor.php +++ b/src/applications/pholio/editor/PholioMockEditor.php @@ -288,7 +288,9 @@ final class PholioMockEditor extends PhabricatorApplicationTransactionEditor { return parent::mergeTransactions($u, $v); } - protected function supportsMail() { + protected function shouldSendMail( + PhabricatorLiskDAO $object, + array $xactions) { return true; } diff --git a/src/applications/ponder/editor/PonderQuestionEditor.php b/src/applications/ponder/editor/PonderQuestionEditor.php index 7f0c098930..978c29cc11 100644 --- a/src/applications/ponder/editor/PonderQuestionEditor.php +++ b/src/applications/ponder/editor/PonderQuestionEditor.php @@ -165,7 +165,9 @@ final class PonderQuestionEditor return parent::shouldImplyCC($object, $xaction); } - protected function supportsMail() { + protected function shouldSendMail( + PhabricatorLiskDAO $object, + array $xactions) { return true; } diff --git a/src/applications/releeph/editor/ReleephRequestTransactionalEditor.php b/src/applications/releeph/editor/ReleephRequestTransactionalEditor.php index 3d7392a93a..56fd690846 100644 --- a/src/applications/releeph/editor/ReleephRequestTransactionalEditor.php +++ b/src/applications/releeph/editor/ReleephRequestTransactionalEditor.php @@ -155,7 +155,9 @@ final class ReleephRequestTransactionalEditor return parent::filterTransactions($object, $xactions); } - protected function supportsMail() { + protected function shouldSendMail( + PhabricatorLiskDAO $object, + array $xactions) { return true; } diff --git a/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php b/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php index 6995cf4802..67cd14eb81 100644 --- a/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php +++ b/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php @@ -457,7 +457,7 @@ abstract class PhabricatorApplicationTransactionEditor $this->loadHandles($xactions); $mail = null; - if ($this->supportsMail()) { + if ($this->shouldSendMail($object, $xactions)) { $mail = $this->sendMail($object, $xactions); } @@ -1069,7 +1069,9 @@ abstract class PhabricatorApplicationTransactionEditor /** * @task mail */ - protected function supportsMail() { + protected function shouldSendMail( + PhabricatorLiskDAO $object, + array $xactions) { return false; }