mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 08:52:39 +01:00
Use TransactionEditor in Differential mail handling
Summary: Ref T2222. Moves this instance of CommentEditor to TransactionEditor. Test Plan: Used `bin/mail receive-test` to test receiving comment mail and action mail. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T2222 Differential Revision: https://secure.phabricator.com/D8427
This commit is contained in:
parent
4dfd4944c4
commit
49eaa9f8fe
2 changed files with 42 additions and 21 deletions
|
@ -129,13 +129,27 @@ class DifferentialReplyHandler extends PhabricatorMailReplyHandler {
|
||||||
|
|
||||||
$body = $this->enhanceBodyWithAttachments($body, $attachments);
|
$body = $this->enhanceBodyWithAttachments($body, $attachments);
|
||||||
|
|
||||||
try {
|
$xactions = array();
|
||||||
$editor = new DifferentialCommentEditor(
|
|
||||||
$this->getMailReceiver(),
|
if ($command && ($command != DifferentialAction::ACTION_COMMENT)) {
|
||||||
$command);
|
$xactions[] = id(new DifferentialTransaction())
|
||||||
$editor->setActor($actor);
|
->setTransactionType(DifferentialTransaction::TYPE_ACTION)
|
||||||
$editor->setExcludeMailRecipientPHIDs(
|
->setNewValue($command);
|
||||||
$this->getExcludeMailRecipientPHIDs());
|
}
|
||||||
|
|
||||||
|
if (strlen($body)) {
|
||||||
|
$xactions[] = id(new DifferentialTransaction())
|
||||||
|
->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)
|
||||||
|
->attachComment(
|
||||||
|
id(new DifferentialTransactionComment())
|
||||||
|
->setContent($body));
|
||||||
|
}
|
||||||
|
|
||||||
|
$editor = id(new DifferentialTransactionEditor())
|
||||||
|
->setActor($actor)
|
||||||
|
->setExcludeMailRecipientPHIDs($this->getExcludeMailRecipientPHIDs())
|
||||||
|
->setContinueOnMissingFields(true)
|
||||||
|
->setContinueOnNoEffect(true);
|
||||||
|
|
||||||
// NOTE: We have to be careful about this because Facebook's
|
// NOTE: We have to be careful about this because Facebook's
|
||||||
// implementation jumps straight into handleAction() and will not have
|
// implementation jumps straight into handleAction() and will not have
|
||||||
|
@ -148,9 +162,15 @@ class DifferentialReplyHandler extends PhabricatorMailReplyHandler {
|
||||||
));
|
));
|
||||||
$editor->setContentSource($content_source);
|
$editor->setContentSource($content_source);
|
||||||
$editor->setParentMessageID($this->receivedMail->getMessageID());
|
$editor->setParentMessageID($this->receivedMail->getMessageID());
|
||||||
|
} else {
|
||||||
|
$content_source = PhabricatorContentSource::newForSource(
|
||||||
|
PhabricatorContentSource::SOURCE_LEGACY,
|
||||||
|
array());
|
||||||
|
$editor->setContentSource($content_source);
|
||||||
}
|
}
|
||||||
$editor->setMessage($body);
|
|
||||||
$editor->save();
|
try {
|
||||||
|
$editor->applyTransactions($this->getMailReceiver(), $xactions);
|
||||||
} catch (Exception $ex) {
|
} catch (Exception $ex) {
|
||||||
if ($this->receivedMail) {
|
if ($this->receivedMail) {
|
||||||
$error_body = $this->receivedMail->getRawTextBody();
|
$error_body = $this->receivedMail->getRawTextBody();
|
||||||
|
|
|
@ -18,6 +18,7 @@ final class DifferentialRevisionMailReceiver
|
||||||
$results = id(new DifferentialRevisionQuery())
|
$results = id(new DifferentialRevisionQuery())
|
||||||
->setViewer($viewer)
|
->setViewer($viewer)
|
||||||
->withIDs(array($id))
|
->withIDs(array($id))
|
||||||
|
->needReviewerStatus(true)
|
||||||
->execute();
|
->execute();
|
||||||
|
|
||||||
return head($results);
|
return head($results);
|
||||||
|
|
Loading…
Reference in a new issue