Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/maniphest/mail/ManiphestReplyHandler.php
12256 views
1
<?php
2
3
final 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
}
56
57