1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 08:52:39 +01:00

Apply Diffusion reply email directly with transaction editor

Summary: Ref T4896. Invoke the new editor directly instead of in a roundabout way when handling Audit email.

Test Plan: Used `bin/mail receive-test` to simulate mail, saw comment post with proper content source.

Reviewers: joshuaspence, btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T4896

Differential Revision: https://secure.phabricator.com/D10127
This commit is contained in:
epriestley 2014-08-02 14:45:27 -07:00
parent 508260e4fe
commit 25acf5d130

View file

@ -33,19 +33,31 @@ final class PhabricatorAuditReplyHandler extends PhabricatorMailReplyHandler {
protected function receiveEmail(PhabricatorMetaMTAReceivedMail $mail) {
$commit = $this->getMailReceiver();
$actor = $this->getActor();
$message = $mail->getCleanTextBody();
$content_source = PhabricatorContentSource::newForSource(
PhabricatorContentSource::SOURCE_EMAIL,
array(
'id' => $mail->getID(),
));
// TODO: Support !raise, !accept, etc.
// TODO: Content sources.
$comment = id(new PhabricatorAuditComment())
->setAction(PhabricatorAuditActionConstants::COMMENT)
->setContent($mail->getCleanTextBody());
$xactions = array();
$editor = new PhabricatorAuditCommentEditor($commit);
$editor->setActor($actor);
$editor->setExcludeMailRecipientPHIDs(
$this->getExcludeMailRecipientPHIDs());
$editor->addComments(array($comment));
$xactions[] = id(new PhabricatorAuditTransaction())
->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)
->attachComment(
id(new PhabricatorAuditTransactionComment())
->setCommitPHID($commit->getPHID())
->setContent($message));
$editor = id(new PhabricatorAuditEditor($commit))
->setActor($actor)
->setContentSource($content_source)
->setExcludeMailRecipientPHIDs($this->getExcludeMailRecipientPHIDs())
->setContinueOnMissingFields(true)
->applyTransactions($commit, $xactions);
}
}