mirror of
https://we.phorge.it/source/phorge.git
synced 2025-03-03 07:59:15 +01:00
Summary: Moves participants over to ModularTransactions, simplified a lot of the code. Fixes T12550 Test Plan: Create a new room with just myself and myself + fake accounts. Remove a person. Remove myself. Edit a room, topic. Type some messages. ??? Profit Reviewers: chad Reviewed By: chad Subscribers: Korvin Maniphest Tasks: T12550 Differential Revision: https://secure.phabricator.com/D17685
75 lines
2.2 KiB
PHP
75 lines
2.2 KiB
PHP
<?php
|
|
|
|
final class ConpherenceReplyHandler extends PhabricatorMailReplyHandler {
|
|
|
|
private $mailAddedParticipantPHIDs;
|
|
|
|
public function setMailAddedParticipantPHIDs(array $phids) {
|
|
$this->mailAddedParticipantPHIDs = $phids;
|
|
return $this;
|
|
}
|
|
public function getMailAddedParticipantPHIDs() {
|
|
return $this->mailAddedParticipantPHIDs;
|
|
}
|
|
|
|
public function validateMailReceiver($mail_receiver) {
|
|
if (!($mail_receiver instanceof ConpherenceThread)) {
|
|
throw new Exception(
|
|
pht(
|
|
'Mail receiver is not a %s!', '
|
|
ConpherenceThread'));
|
|
}
|
|
}
|
|
|
|
public function getPrivateReplyHandlerEmailAddress(PhabricatorUser $user) {
|
|
return $this->getDefaultPrivateReplyHandlerEmailAddress($user, 'Z');
|
|
}
|
|
|
|
public function getPublicReplyHandlerEmailAddress() {
|
|
return $this->getDefaultPublicReplyHandlerEmailAddress('Z');
|
|
}
|
|
|
|
protected function receiveEmail(PhabricatorMetaMTAReceivedMail $mail) {
|
|
$conpherence = $this->getMailReceiver();
|
|
$user = $this->getActor();
|
|
if (!$conpherence->getPHID()) {
|
|
$conpherence
|
|
->attachParticipants(array());
|
|
} else {
|
|
$participants = id(new ConpherenceParticipant())
|
|
->loadAllWhere('conpherencePHID = %s', $conpherence->getPHID());
|
|
$participants = mpull($participants, null, 'getParticipantPHID');
|
|
$conpherence->attachParticipants($participants);
|
|
}
|
|
|
|
$content_source = $mail->newContentSource();
|
|
|
|
$editor = id(new ConpherenceEditor())
|
|
->setActor($user)
|
|
->setContentSource($content_source)
|
|
->setParentMessageID($mail->getMessageID());
|
|
|
|
$body = $mail->getCleanTextBody();
|
|
$body = $this->enhanceBodyWithAttachments($body, $mail->getAttachments());
|
|
|
|
$xactions = array();
|
|
if ($this->getMailAddedParticipantPHIDs()) {
|
|
$xactions[] = id(new ConpherenceTransaction())
|
|
->setTransactionType(
|
|
ConpherenceThreadParticipantsTransaction::TRANSACTIONTYPE)
|
|
->setNewValue(array('+' => $this->getMailAddedParticipantPHIDs()));
|
|
}
|
|
|
|
$xactions = array_merge(
|
|
$xactions,
|
|
$editor->generateTransactionsFromText(
|
|
$user,
|
|
$conpherence,
|
|
$body));
|
|
|
|
$editor->applyTransactions($conpherence, $xactions);
|
|
|
|
return $conpherence;
|
|
}
|
|
|
|
}
|