mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-30 02:32:42 +01:00
Merge branch 'master' of github.com:facebook/phabricator
This commit is contained in:
commit
3fcd8429f5
2 changed files with 85 additions and 0 deletions
|
@ -147,6 +147,7 @@ phutil_register_library_map(array(
|
|||
'ConduitAPI_diffusion_browsequery_Method' => 'applications/diffusion/conduit/ConduitAPI_diffusion_browsequery_Method.php',
|
||||
'ConduitAPI_diffusion_commitbranchesquery_Method' => 'applications/diffusion/conduit/ConduitAPI_diffusion_commitbranchesquery_Method.php',
|
||||
'ConduitAPI_diffusion_commitparentsquery_Method' => 'applications/diffusion/conduit/ConduitAPI_diffusion_commitparentsquery_Method.php',
|
||||
'ConduitAPI_diffusion_createcomment_Method' => 'applications/diffusion/conduit/ConduitAPI_diffusion_createcomment_Method.php',
|
||||
'ConduitAPI_diffusion_diffquery_Method' => 'applications/diffusion/conduit/ConduitAPI_diffusion_diffquery_Method.php',
|
||||
'ConduitAPI_diffusion_existsquery_Method' => 'applications/diffusion/conduit/ConduitAPI_diffusion_existsquery_Method.php',
|
||||
'ConduitAPI_diffusion_expandshortcommitquery_Method' => 'applications/diffusion/conduit/ConduitAPI_diffusion_expandshortcommitquery_Method.php',
|
||||
|
@ -2197,6 +2198,7 @@ phutil_register_library_map(array(
|
|||
'ConduitAPI_diffusion_browsequery_Method' => 'ConduitAPI_diffusion_abstractquery_Method',
|
||||
'ConduitAPI_diffusion_commitbranchesquery_Method' => 'ConduitAPI_diffusion_abstractquery_Method',
|
||||
'ConduitAPI_diffusion_commitparentsquery_Method' => 'ConduitAPI_diffusion_abstractquery_Method',
|
||||
'ConduitAPI_diffusion_createcomment_Method' => 'ConduitAPI_diffusion_Method',
|
||||
'ConduitAPI_diffusion_diffquery_Method' => 'ConduitAPI_diffusion_abstractquery_Method',
|
||||
'ConduitAPI_diffusion_existsquery_Method' => 'ConduitAPI_diffusion_abstractquery_Method',
|
||||
'ConduitAPI_diffusion_expandshortcommitquery_Method' => 'ConduitAPI_diffusion_abstractquery_Method',
|
||||
|
|
|
@ -0,0 +1,83 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
*@group conduit
|
||||
*/
|
||||
final class ConduitAPI_diffusion_createcomment_Method
|
||||
extends ConduitAPI_diffusion_Method {
|
||||
|
||||
public function getMethodStatus() {
|
||||
return self::METHOD_STATUS_DEPRECATED;
|
||||
}
|
||||
|
||||
public function getMethodDescription() {
|
||||
return 'Add a comment to a Diffusion commit. By specifying an action of '.
|
||||
'"concern", "accept", "resign", or "close", auditing actions can '.
|
||||
'be triggered. Defaults to "comment".';
|
||||
}
|
||||
|
||||
public function defineParamTypes() {
|
||||
return array(
|
||||
'phid' => 'required string',
|
||||
'action' => 'optional string',
|
||||
'message' => 'required string',
|
||||
);
|
||||
}
|
||||
|
||||
public function defineReturnType() {
|
||||
return 'bool';
|
||||
}
|
||||
|
||||
public function defineErrorTypes() {
|
||||
return array(
|
||||
'ERR_BAD_COMMIT' => 'No commit found with that PHID',
|
||||
'ERR_BAD_ACTION' => 'Invalid action type',
|
||||
'ERR_MISSING_MESSAGE' => 'Message is required',
|
||||
);
|
||||
}
|
||||
|
||||
protected function execute(ConduitAPIRequest $request) {
|
||||
$commit_phid = $request->getValue('phid');
|
||||
$commit = id(new PhabricatorRepositoryCommit())->loadOneWhere(
|
||||
'phid = %s',
|
||||
$commit_phid);
|
||||
|
||||
if (!$commit) {
|
||||
throw new ConduitException('ERR_BAD_COMMIT');
|
||||
}
|
||||
|
||||
$message = trim($request->getValue('message'));
|
||||
if (!$message) {
|
||||
throw new ConduitException('ERR_MISSING_MESSAGE');
|
||||
}
|
||||
|
||||
$action = $request->getValue('action');
|
||||
if (!$action) {
|
||||
$action = PhabricatorAuditActionConstants::COMMENT;
|
||||
}
|
||||
|
||||
// Disallow ADD_CCS, ADD_AUDITORS for now
|
||||
if (!in_array($action, array(
|
||||
PhabricatorAuditActionConstants::CONCERN,
|
||||
PhabricatorAuditActionConstants::ACCEPT,
|
||||
PhabricatorAuditActionConstants::COMMENT,
|
||||
PhabricatorAuditActionConstants::RESIGN,
|
||||
PhabricatorAuditActionConstants::CLOSE,
|
||||
))) {
|
||||
throw new ConduitException('ERR_BAD_ACTION');
|
||||
}
|
||||
|
||||
$comment = id(new PhabricatorAuditComment())
|
||||
->setAction($action)
|
||||
->setContent($message);
|
||||
|
||||
id(new PhabricatorAuditCommentEditor($commit))
|
||||
->setActor($request->getUser())
|
||||
->addComment($comment);
|
||||
|
||||
return true;
|
||||
// get the full uri of the comment?
|
||||
// i.e, PhabricatorEnv::getURI(rXX01ab23cd#comment-9)
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue