@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 ConpherenceReplyHandler extends PhabricatorMailReplyHandler {
4
5 private $mailAddedParticipantPHIDs;
6
7 public function setMailAddedParticipantPHIDs(array $phids) {
8 $this->mailAddedParticipantPHIDs = $phids;
9 return $this;
10 }
11 public function getMailAddedParticipantPHIDs() {
12 return $this->mailAddedParticipantPHIDs;
13 }
14
15 public function validateMailReceiver($mail_receiver) {
16 if (!($mail_receiver instanceof ConpherenceThread)) {
17 throw new Exception(
18 pht(
19 'Mail receiver is not a %s!', '
20 ConpherenceThread'));
21 }
22 }
23
24 public function getPrivateReplyHandlerEmailAddress(PhabricatorUser $user) {
25 return $this->getDefaultPrivateReplyHandlerEmailAddress($user, 'Z');
26 }
27
28 public function getPublicReplyHandlerEmailAddress() {
29 return $this->getDefaultPublicReplyHandlerEmailAddress('Z');
30 }
31
32 protected function receiveEmail(PhabricatorMetaMTAReceivedMail $mail) {
33 $conpherence = $this->getMailReceiver();
34 $user = $this->getActor();
35 if (!$conpherence->getPHID()) {
36 $conpherence
37 ->attachParticipants(array());
38 } else {
39 $participants = id(new ConpherenceParticipant())
40 ->loadAllWhere('conpherencePHID = %s', $conpherence->getPHID());
41 $participants = mpull($participants, null, 'getParticipantPHID');
42 $conpherence->attachParticipants($participants);
43 }
44
45 $content_source = $mail->newContentSource();
46
47 $editor = id(new ConpherenceEditor())
48 ->setActor($user)
49 ->setContentSource($content_source)
50 ->setParentMessageID($mail->getMessageID());
51
52 $body = $mail->getCleanTextBody();
53 $body = $this->enhanceBodyWithAttachments($body, $mail->getAttachments());
54
55 $xactions = array();
56 if ($this->getMailAddedParticipantPHIDs()) {
57 $xactions[] = id(new ConpherenceTransaction())
58 ->setTransactionType(
59 ConpherenceThreadParticipantsTransaction::TRANSACTIONTYPE)
60 ->setNewValue(array('+' => $this->getMailAddedParticipantPHIDs()));
61 }
62
63 $xactions = array_merge(
64 $xactions,
65 $editor->generateTransactionsFromText(
66 $user,
67 $conpherence,
68 $body));
69
70 $editor->applyTransactions($conpherence, $xactions);
71
72 return $conpherence;
73 }
74
75}