Changeset View
Changeset View
Standalone View
Standalone View
src/applications/ponder/mail/PonderQuestionCreateMailReceiver.php
<?php | <?php | ||||
final class PonderQuestionCreateMailReceiver | final class PonderQuestionCreateMailReceiver | ||||
extends PhabricatorApplicationMailReceiver { | extends PhabricatorApplicationMailReceiver { | ||||
protected function newApplication() { | protected function newApplication() { | ||||
return new PhabricatorPonderApplication(); | return new PhabricatorPonderApplication(); | ||||
} | } | ||||
protected function processReceivedMail( | protected function processReceivedMail( | ||||
PhabricatorMetaMTAReceivedMail $mail, | PhabricatorMetaMTAReceivedMail $mail, | ||||
PhabricatorUser $sender) { | PhutilEmailAddress $target) { | ||||
$author = $this->getAuthor(); | |||||
$title = $mail->getSubject(); | $title = $mail->getSubject(); | ||||
if (!strlen($title)) { | if (!strlen($title)) { | ||||
$title = pht('New Question'); | $title = pht('New Question'); | ||||
} | } | ||||
$xactions = array(); | $xactions = array(); | ||||
$xactions[] = id(new PonderQuestionTransaction()) | $xactions[] = id(new PonderQuestionTransaction()) | ||||
->setTransactionType(PonderQuestionTransaction::TYPE_TITLE) | ->setTransactionType(PonderQuestionTransaction::TYPE_TITLE) | ||||
->setNewValue($title); | ->setNewValue($title); | ||||
$xactions[] = id(new PonderQuestionTransaction()) | $xactions[] = id(new PonderQuestionTransaction()) | ||||
->setTransactionType(PonderQuestionTransaction::TYPE_CONTENT) | ->setTransactionType(PonderQuestionTransaction::TYPE_CONTENT) | ||||
->setNewValue($mail->getCleanTextBody()); | ->setNewValue($mail->getCleanTextBody()); | ||||
$question = PonderQuestion::initializeNewQuestion($sender); | $question = PonderQuestion::initializeNewQuestion($author); | ||||
$content_source = $mail->newContentSource(); | $content_source = $mail->newContentSource(); | ||||
$editor = id(new PonderQuestionEditor()) | $editor = id(new PonderQuestionEditor()) | ||||
->setActor($sender) | ->setActor($author) | ||||
->setContentSource($content_source) | ->setContentSource($content_source) | ||||
->setContinueOnNoEffect(true); | ->setContinueOnNoEffect(true); | ||||
$xactions = $editor->applyTransactions($question, $xactions); | $xactions = $editor->applyTransactions($question, $xactions); | ||||
$mail->setRelatedPHID($question->getPHID()); | $mail->setRelatedPHID($question->getPHID()); | ||||
} | } | ||||
} | } |