1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-19 13:22:42 +01:00

Apply diffusion.createcomment directly with transaction editor in Audit

Summary: Ref T4896. Use the new transaction-oriented `PhabricatorAuditEditor` directly instead of invoking it via the old editor.

Test Plan: Used Conduit to add a comment, use silent mode, and accept a commit.

Reviewers: joshuaspence, btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T4896

Differential Revision: https://secure.phabricator.com/D10126
This commit is contained in:
epriestley 2014-08-02 14:45:09 -07:00
parent a297450aa9
commit 508260e4fe
2 changed files with 16 additions and 19 deletions

View file

@ -4,7 +4,6 @@ final class PhabricatorAuditCommentEditor extends PhabricatorEditor {
private $commit; private $commit;
private $attachInlineComments; private $attachInlineComments;
private $noEmail;
public function __construct(PhabricatorRepositoryCommit $commit) { public function __construct(PhabricatorRepositoryCommit $commit) {
$this->commit = $commit; $this->commit = $commit;
@ -16,11 +15,6 @@ final class PhabricatorAuditCommentEditor extends PhabricatorEditor {
return $this; return $this;
} }
public function setNoEmail($no_email) {
$this->noEmail = $no_email;
return $this;
}
public function addComments(array $comments) { public function addComments(array $comments) {
assert_instances_of($comments, 'PhabricatorAuditComment'); assert_instances_of($comments, 'PhabricatorAuditComment');
@ -62,7 +56,6 @@ final class PhabricatorAuditCommentEditor extends PhabricatorEditor {
->setContinueOnMissingFields(true) ->setContinueOnMissingFields(true)
->setContentSource($content_source) ->setContentSource($content_source)
->setExcludeMailRecipientPHIDs($this->getExcludeMailRecipientPHIDs()) ->setExcludeMailRecipientPHIDs($this->getExcludeMailRecipientPHIDs())
->setDisableEmail($this->noEmail)
->applyTransactions($commit, $xactions); ->applyTransactions($commit, $xactions);
} }

View file

@ -59,7 +59,7 @@ final class DiffusionCreateCommentConduitAPIMethod
$action = PhabricatorAuditActionConstants::COMMENT; $action = PhabricatorAuditActionConstants::COMMENT;
} }
// Disallow ADD_CCS, ADD_AUDITORS for now // Disallow ADD_CCS, ADD_AUDITORS forever.
if (!in_array($action, array( if (!in_array($action, array(
PhabricatorAuditActionConstants::CONCERN, PhabricatorAuditActionConstants::CONCERN,
PhabricatorAuditActionConstants::ACCEPT, PhabricatorAuditActionConstants::ACCEPT,
@ -70,27 +70,31 @@ final class DiffusionCreateCommentConduitAPIMethod
throw new ConduitException('ERR_BAD_ACTION'); throw new ConduitException('ERR_BAD_ACTION');
} }
$comments = array(); $xactions = array();
if ($action != PhabricatorAuditActionConstants::COMMENT) { if ($action != PhabricatorAuditActionConstants::COMMENT) {
$comments[] = id(new PhabricatorAuditComment()) $xactions[] = id(new PhabricatorAuditTransaction())
->setAction($action); ->setTransactionType(PhabricatorAuditActionConstants::ACTION)
->setNewValue($action);
} }
if (strlen($message)) { if (strlen($message)) {
$comments[] = id(new PhabricatorAuditComment()) $xactions[] = id(new PhabricatorAuditTransaction())
->setAction(PhabricatorAuditActionConstants::COMMENT) ->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)
->setContent($message); ->attachComment(
id(new PhabricatorAuditTransactionComment())
->setCommitPHID($commit->getPHID())
->setContent($message));
} }
id(new PhabricatorAuditCommentEditor($commit)) id(new PhabricatorAuditEditor())
->setActor($request->getUser()) ->setActor($request->getUser())
->setNoEmail($request->getValue('silent')) ->setContentSourceFromConduitRequest($request)
->addComments($comments); ->setDisableEmail($request->getValue('silent'))
->setContinueOnMissingFields(true)
->applyTransactions($commit, $xactions);
return true; return true;
// get the full uri of the comment?
// i.e, PhabricatorEnv::getURI(rXX01ab23cd#comment-9)
} }
} }