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 @@ -4062,6 +4062,7 @@ 'PonderModerateCapability' => 'applications/ponder/capability/PonderModerateCapability.php', 'PonderQuestion' => 'applications/ponder/storage/PonderQuestion.php', 'PonderQuestionCommentController' => 'applications/ponder/controller/PonderQuestionCommentController.php', + 'PonderQuestionCreateMailReceiver' => 'applications/ponder/mail/PonderQuestionCreateMailReceiver.php', 'PonderQuestionEditController' => 'applications/ponder/controller/PonderQuestionEditController.php', 'PonderQuestionEditor' => 'applications/ponder/editor/PonderQuestionEditor.php', 'PonderQuestionFulltextEngine' => 'applications/ponder/search/PonderQuestionFulltextEngine.php', @@ -9013,6 +9014,7 @@ 'PhabricatorFulltextInterface', ), 'PonderQuestionCommentController' => 'PonderController', + 'PonderQuestionCreateMailReceiver' => 'PhabricatorMailReceiver', 'PonderQuestionEditController' => 'PonderController', 'PonderQuestionEditor' => 'PonderEditor', 'PonderQuestionFulltextEngine' => 'PhabricatorFulltextEngine', diff --git a/src/applications/ponder/application/PhabricatorPonderApplication.php b/src/applications/ponder/application/PhabricatorPonderApplication.php --- a/src/applications/ponder/application/PhabricatorPonderApplication.php +++ b/src/applications/ponder/application/PhabricatorPonderApplication.php @@ -34,6 +34,21 @@ ); } + public function supportsEmailIntegration() { + return true; + } + + public function getAppEmailBlurb() { + return pht( + 'Send email to these addresses to create questions. %s', + phutil_tag( + 'a', + array( + 'href' => $this->getInboundEmailSupportLink(), + ), + pht('Learn More'))); + } + public function getRoutes() { return array( '/Q(?P[1-9]\d*)' diff --git a/src/applications/ponder/mail/PonderQuestionCreateMailReceiver.php b/src/applications/ponder/mail/PonderQuestionCreateMailReceiver.php new file mode 100644 --- /dev/null +++ b/src/applications/ponder/mail/PonderQuestionCreateMailReceiver.php @@ -0,0 +1,49 @@ +canAcceptApplicationMail($ponder_app, $mail); + } + + protected function processReceivedMail( + PhabricatorMetaMTAReceivedMail $mail, + PhabricatorUser $sender) { + + $title = $mail->getSubject(); + if (!strlen($title)) { + $title = pht('New Question'); + } + + $xactions = array(); + + $xactions[] = id(new PonderQuestionTransaction()) + ->setTransactionType(PonderQuestionTransaction::TYPE_TITLE) + ->setNewValue($title); + + $xactions[] = id(new PonderQuestionTransaction()) + ->setTransactionType(PonderQuestionTransaction::TYPE_CONTENT) + ->setNewValue($mail->getCleanTextBody()); + + $question = PonderQuestion::initializeNewQuestion($sender); + + $content_source = $mail->newContentSource(); + + $editor = id(new PonderQuestionEditor()) + ->setActor($sender) + ->setContentSource($content_source) + ->setContinueOnNoEffect(true); + $xactions = $editor->applyTransactions($question, $xactions); + + $mail->setRelatedPHID($question->getPHID()); + + } + + +} diff --git a/src/applications/ponder/storage/PonderQuestion.php b/src/applications/ponder/storage/PonderQuestion.php --- a/src/applications/ponder/storage/PonderQuestion.php +++ b/src/applications/ponder/storage/PonderQuestion.php @@ -48,6 +48,7 @@ ->setViewPolicy($view_policy) ->setStatus(PonderQuestionStatus::STATUS_OPEN) ->setAnswerCount(0) + ->setAnswerWiki('') ->setSpacePHID($actor->getDefaultSpacePHID()); }