Page MenuHomePhabricator

D13905.diff
No OneTemporary

D13905.diff

diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -3406,8 +3406,10 @@
'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 @@
'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 @@
'PonderAnswerEditor' => 'PonderEditor',
'PonderAnswerHasVotingUserEdgeType' => 'PhabricatorEdgeType',
'PonderAnswerHistoryController' => 'PonderController',
+ 'PonderAnswerMailReceiver' => 'PhabricatorObjectMailReceiver',
'PonderAnswerPHIDType' => 'PhabricatorPHIDType',
'PonderAnswerQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
+ 'PonderAnswerReplyHandler' => 'PhabricatorApplicationTransactionReplyHandler',
'PonderAnswerSaveController' => 'PonderController',
'PonderAnswerStatus' => 'PonderConstants',
'PonderAnswerTransaction' => 'PhabricatorApplicationTransaction',
@@ -7654,7 +7657,6 @@
'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
--- a/src/applications/ponder/editor/PonderQuestionEditor.php
+++ b/src/applications/ponder/editor/PonderQuestionEditor.php
@@ -177,30 +177,13 @@
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 @@
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 @@
$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
--- a/src/applications/ponder/feed/PonderTransactionFeedStory.php
+++ /dev/null
@@ -1,14 +0,0 @@
-<?php
-
-final class PonderTransactionFeedStory
- extends PhabricatorApplicationTransactionFeedStory {
-
- public function getRequiredObjectPHIDs() {
- $phids = parent::getRequiredObjectPHIDs();
- $answer_phid = $this->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
--- /dev/null
+++ b/src/applications/ponder/mail/PonderAnswerMailReceiver.php
@@ -0,0 +1,27 @@
+<?php
+
+final class PonderAnswerMailReceiver extends PhabricatorObjectMailReceiver {
+
+ public function isEnabled() {
+ $app_class = 'PhabricatorPonderApplication';
+ return PhabricatorApplication::isClassInstalled($app_class);
+ }
+
+ protected function getObjectPattern() {
+ return 'ANSR[1-9]\d*';
+ }
+
+ protected function loadObject($pattern, PhabricatorUser $viewer) {
+ $id = (int)trim($pattern, 'ANSR');
+
+ return id(new PonderAnswerQuery())
+ ->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
--- /dev/null
+++ b/src/applications/ponder/mail/PonderAnswerReplyHandler.php
@@ -0,0 +1,16 @@
+<?php
+
+final class PonderAnswerReplyHandler
+ extends PhabricatorApplicationTransactionReplyHandler {
+
+ public function validateMailReceiver($mail_receiver) {
+ if (!($mail_receiver instanceof PonderAnswer)) {
+ throw new Exception(pht('Mail receiver is not a %s!', 'PonderAnswer'));
+ }
+ }
+
+ public function getObjectPrefix() {
+ return 'ANSR';
+ }
+
+}
diff --git a/src/applications/ponder/storage/PonderQuestionTransaction.php b/src/applications/ponder/storage/PonderQuestionTransaction.php
--- a/src/applications/ponder/storage/PonderQuestionTransaction.php
+++ b/src/applications/ponder/storage/PonderQuestionTransaction.php
@@ -336,23 +336,4 @@
return reset($add);
}
- /**
- * Generally, the answer object is only available if the transaction
- * type is `self::TYPE_ANSWERS`.
- *
- * Some stories - notably ones made before D7027 - will be of the more
- * generic @{class:PhabricatorApplicationTransactionFeedStory}. These
- * poor stories won't have the PonderAnswer loaded, and thus will have
- * less cool information.
- */
- private function getNewAnswerObject(PhabricatorFeedStory $story) {
- if ($story instanceof PonderTransactionFeedStory) {
- $answer_phid = $this->getNewAnswerPHID();
- if ($answer_phid) {
- return $story->getObject($answer_phid);
- }
- }
- return null;
- }
-
}

File Metadata

Mime Type
text/plain
Expires
Wed, Dec 25, 9:46 PM (12 h, 14 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6927697
Default Alt Text
D13905.diff (7 KB)

Event Timeline