@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.)
hq.recaptime.dev/wiki/Phorge
phorge
phabricator
1<?php
2
3final class PonderQuestionCreateMailReceiver
4 extends PhabricatorApplicationMailReceiver {
5
6 protected function newApplication() {
7 return new PhabricatorPonderApplication();
8 }
9
10 protected function processReceivedMail(
11 PhabricatorMetaMTAReceivedMail $mail,
12 PhutilEmailAddress $target) {
13 $author = $this->getAuthor();
14
15 $title = $mail->getSubject();
16 if (!strlen($title)) {
17 $title = pht('New Question');
18 }
19
20 $xactions = array();
21
22 $xactions[] = id(new PonderQuestionTransaction())
23 ->setTransactionType(PonderQuestionTitleTransaction::TRANSACTIONTYPE)
24 ->setNewValue($title);
25
26 $xactions[] = id(new PonderQuestionTransaction())
27 ->setTransactionType(PonderQuestionContentTransaction::TRANSACTIONTYPE)
28 ->setNewValue($mail->getCleanTextBody());
29
30 $question = PonderQuestion::initializeNewQuestion($author);
31
32 $content_source = $mail->newContentSource();
33
34 $editor = id(new PonderQuestionEditor())
35 ->setActor($author)
36 ->setContentSource($content_source)
37 ->setContinueOnNoEffect(true);
38 $xactions = $editor->applyTransactions($question, $xactions);
39
40 $mail->setRelatedPHID($question->getPHID());
41 }
42
43
44}