From ee8e4363900edfc10c205695e3357bb96bd33db4 Mon Sep 17 00:00:00 2001 From: Chad Little Date: Mon, 17 Aug 2015 10:22:54 -0700 Subject: [PATCH] Add ability to reply to Ponder Answer emails Summary: Ref T9068, Ref T3846. Maybe fixes both, but I'm having issues testing email replies in a sandbox. Moves answer feed/mail generation to the AnswerEditor, hides it in QuestionEditor. Test Plan: Write an answer, see feed story, check /mail/ for mail generation. Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin Maniphest Tasks: T3846, T9068 Differential Revision: https://secure.phabricator.com/D13905 --- src/__phutil_library_map__.php | 6 ++- .../ponder/editor/PonderQuestionEditor.php | 47 ++++++++----------- .../feed/PonderTransactionFeedStory.php | 14 ------ .../ponder/mail/PonderAnswerMailReceiver.php | 27 +++++++++++ .../ponder/mail/PonderAnswerReplyHandler.php | 16 +++++++ .../storage/PonderQuestionTransaction.php | 19 -------- 6 files changed, 67 insertions(+), 62 deletions(-) delete mode 100644 src/applications/ponder/feed/PonderTransactionFeedStory.php create mode 100644 src/applications/ponder/mail/PonderAnswerMailReceiver.php create mode 100644 src/applications/ponder/mail/PonderAnswerReplyHandler.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index e589155500..3023eceaed 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -3406,8 +3406,10 @@ phutil_register_library_map(array( 'PonderAnswerEditor' => 'applications/ponder/editor/PonderAnswerEditor.php', 'PonderAnswerHasVotingUserEdgeType' => 'applications/ponder/edge/PonderAnswerHasVotingUserEdgeType.php', 'PonderAnswerHistoryController' => 'applications/ponder/controller/PonderAnswerHistoryController.php', + 'PonderAnswerMailReceiver' => 'applications/ponder/mail/PonderAnswerMailReceiver.php', 'PonderAnswerPHIDType' => 'applications/ponder/phid/PonderAnswerPHIDType.php', 'PonderAnswerQuery' => 'applications/ponder/query/PonderAnswerQuery.php', + 'PonderAnswerReplyHandler' => 'applications/ponder/mail/PonderAnswerReplyHandler.php', 'PonderAnswerSaveController' => 'applications/ponder/controller/PonderAnswerSaveController.php', 'PonderAnswerStatus' => 'applications/ponder/constants/PonderAnswerStatus.php', 'PonderAnswerTransaction' => 'applications/ponder/storage/PonderAnswerTransaction.php', @@ -3442,7 +3444,6 @@ phutil_register_library_map(array( 'PonderRemarkupRule' => 'applications/ponder/remarkup/PonderRemarkupRule.php', 'PonderSchemaSpec' => 'applications/ponder/storage/PonderSchemaSpec.php', 'PonderSearchIndexer' => 'applications/ponder/search/PonderSearchIndexer.php', - 'PonderTransactionFeedStory' => 'applications/ponder/feed/PonderTransactionFeedStory.php', 'PonderVotableInterface' => 'applications/ponder/storage/PonderVotableInterface.php', 'PonderVote' => 'applications/ponder/constants/PonderVote.php', 'PonderVoteEditor' => 'applications/ponder/editor/PonderVoteEditor.php', @@ -7607,8 +7608,10 @@ phutil_register_library_map(array( 'PonderAnswerEditor' => 'PonderEditor', 'PonderAnswerHasVotingUserEdgeType' => 'PhabricatorEdgeType', 'PonderAnswerHistoryController' => 'PonderController', + 'PonderAnswerMailReceiver' => 'PhabricatorObjectMailReceiver', 'PonderAnswerPHIDType' => 'PhabricatorPHIDType', 'PonderAnswerQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', + 'PonderAnswerReplyHandler' => 'PhabricatorApplicationTransactionReplyHandler', 'PonderAnswerSaveController' => 'PonderController', 'PonderAnswerStatus' => 'PonderConstants', 'PonderAnswerTransaction' => 'PhabricatorApplicationTransaction', @@ -7654,7 +7657,6 @@ phutil_register_library_map(array( 'PonderRemarkupRule' => 'PhabricatorObjectRemarkupRule', 'PonderSchemaSpec' => 'PhabricatorConfigSchemaSpec', 'PonderSearchIndexer' => 'PhabricatorSearchDocumentIndexer', - 'PonderTransactionFeedStory' => 'PhabricatorApplicationTransactionFeedStory', 'PonderVote' => 'PonderConstants', 'PonderVoteEditor' => 'PhabricatorEditor', 'PonderVotingUserHasAnswerEdgeType' => 'PhabricatorEdgeType', diff --git a/src/applications/ponder/editor/PonderQuestionEditor.php b/src/applications/ponder/editor/PonderQuestionEditor.php index eeac4b3414..2fbe629002 100644 --- a/src/applications/ponder/editor/PonderQuestionEditor.php +++ b/src/applications/ponder/editor/PonderQuestionEditor.php @@ -177,30 +177,13 @@ final class PonderQuestionEditor return true; } - protected function getFeedStoryType() { - return 'PonderTransactionFeedStory'; - } - - protected function getFeedStoryData( - PhabricatorLiskDAO $object, - array $xactions) { - - $data = parent::getFeedStoryData($object, $xactions); - $answer = $this->getAnswer(); - if ($answer) { - $data['answerPHID'] = $answer->getPHID(); - } - - return $data; - } - protected function shouldImplyCC( PhabricatorLiskDAO $object, PhabricatorApplicationTransaction $xaction) { switch ($xaction->getTransactionType()) { case PonderQuestionTransaction::TYPE_ANSWERS: - return true; + return false; } return parent::shouldImplyCC($object, $xaction); @@ -209,7 +192,25 @@ final class PonderQuestionEditor protected function shouldSendMail( PhabricatorLiskDAO $object, array $xactions) { - return true; + foreach ($xactions as $xaction) { + switch ($xaction->getTransactionType()) { + case PonderQuestionTransaction::TYPE_ANSWERS: + return false; + } + } + return true; + } + + protected function shouldPublishFeedStory( + PhabricatorLiskDAO $object, + array $xactions) { + foreach ($xactions as $xaction) { + switch ($xaction->getTransactionType()) { + case PonderQuestionTransaction::TYPE_ANSWERS: + return false; + } + } + return true; } public function getMailTagsMap() { @@ -248,14 +249,6 @@ final class PonderQuestionEditor $body->addRawSection($new); } } - // If the user gave an answer, add the answer text. Also update - // the header and uri to be more answer-specific. - if ($type == PonderQuestionTransaction::TYPE_ANSWERS) { - $answer = $this->getAnswer(); - $body->addRawSection($answer->getContent()); - $header = pht('ANSWER DETAIL'); - $uri = $answer->getURI(); - } } $body->addLinkSection( diff --git a/src/applications/ponder/feed/PonderTransactionFeedStory.php b/src/applications/ponder/feed/PonderTransactionFeedStory.php deleted file mode 100644 index 354170af51..0000000000 --- a/src/applications/ponder/feed/PonderTransactionFeedStory.php +++ /dev/null @@ -1,14 +0,0 @@ -getValue('answerPHID'); - if ($answer_phid) { - $phids[] = $answer_phid; - } - return $phids; - } -} diff --git a/src/applications/ponder/mail/PonderAnswerMailReceiver.php b/src/applications/ponder/mail/PonderAnswerMailReceiver.php new file mode 100644 index 0000000000..d7269ac861 --- /dev/null +++ b/src/applications/ponder/mail/PonderAnswerMailReceiver.php @@ -0,0 +1,27 @@ +setViewer($viewer) + ->withIDs(array($id)) + ->executeOne(); + } + + protected function getTransactionReplyHandler() { + return new PonderAnswerReplyHandler(); + } + +} diff --git a/src/applications/ponder/mail/PonderAnswerReplyHandler.php b/src/applications/ponder/mail/PonderAnswerReplyHandler.php new file mode 100644 index 0000000000..bfc077a7ad --- /dev/null +++ b/src/applications/ponder/mail/PonderAnswerReplyHandler.php @@ -0,0 +1,16 @@ +getNewAnswerPHID(); - if ($answer_phid) { - return $story->getObject($answer_phid); - } - } - return null; - } - }