1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-19 20:10:55 +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 $attachInlineComments;
private $noEmail;
public function __construct(PhabricatorRepositoryCommit $commit) {
$this->commit = $commit;
@ -16,11 +15,6 @@ final class PhabricatorAuditCommentEditor extends PhabricatorEditor {
return $this;
}
public function setNoEmail($no_email) {
$this->noEmail = $no_email;
return $this;
}
public function addComments(array $comments) {
assert_instances_of($comments, 'PhabricatorAuditComment');
@ -62,7 +56,6 @@ final class PhabricatorAuditCommentEditor extends PhabricatorEditor {
->setContinueOnMissingFields(true)
->setContentSource($content_source)
->setExcludeMailRecipientPHIDs($this->getExcludeMailRecipientPHIDs())
->setDisableEmail($this->noEmail)
->applyTransactions($commit, $xactions);
}

View file

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