@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 ManiphestReplyHandler
4 extends PhabricatorApplicationTransactionReplyHandler {
5
6 public function validateMailReceiver($mail_receiver) {
7 if (!($mail_receiver instanceof ManiphestTask)) {
8 throw new Exception(pht('Mail receiver is not a %s!', 'ManiphestTask'));
9 }
10 }
11
12 public function getObjectPrefix() {
13 return 'T';
14 }
15
16 protected function didReceiveMail(
17 PhabricatorMetaMTAReceivedMail $mail,
18 $body) {
19
20 $object = $this->getMailReceiver();
21 $is_new = !$object->getID();
22 $actor = $this->getActor();
23
24 $xactions = array();
25
26 if ($is_new) {
27 $xactions[] = $this->newTransaction()
28 ->setTransactionType(PhabricatorTransactions::TYPE_CREATE)
29 ->setNewValue(true);
30
31 $xactions[] = $this->newTransaction()
32 ->setTransactionType(ManiphestTaskTitleTransaction::TRANSACTIONTYPE)
33 ->setNewValue(nonempty($mail->getSubject(), pht('Untitled Task')));
34
35 $xactions[] = $this->newTransaction()
36 ->setTransactionType(
37 ManiphestTaskDescriptionTransaction::TRANSACTIONTYPE)
38 ->setNewValue($body);
39
40 $actor_phid = $actor->getPHID();
41 if ($actor_phid) {
42 $xactions[] = $this->newTransaction()
43 ->setTransactionType(PhabricatorTransactions::TYPE_SUBSCRIBERS)
44 ->setNewValue(
45 array(
46 '+' => array($actor_phid),
47 ));
48 }
49 }
50
51 return $xactions;
52 }
53
54
55}