mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-18 19:40:55 +01:00
Add a "createcomment" method to Differential
Summary: Added a new method differential.createcomment Task ID: #752014 Test Plan: I created a test diff and called this method via the conduit from a client PHP script to add comments. I confirmed that 1) the comment appeared on the revision, 2) URLs within the comment were turned into hyperlinks, and 3) Phabricator sent a notification email to the people watching the test diff. Reviewers: nh, jungejason, epriestley Reviewed By: nh CC: aran, nh Differential Revision: 1128
This commit is contained in:
parent
e9693f25f8
commit
5dba8abceb
3 changed files with 92 additions and 0 deletions
|
@ -94,6 +94,7 @@ phutil_register_library_map(array(
|
|||
'ConduitAPI_conduit_ping_Method' => 'applications/conduit/method/conduit/ping',
|
||||
'ConduitAPI_daemon_launched_Method' => 'applications/conduit/method/daemon/launched',
|
||||
'ConduitAPI_daemon_log_Method' => 'applications/conduit/method/daemon/log',
|
||||
'ConduitAPI_differential_createcomment_Method' => 'applications/conduit/method/differential/createcomment',
|
||||
'ConduitAPI_differential_creatediff_Method' => 'applications/conduit/method/differential/creatediff',
|
||||
'ConduitAPI_differential_createrevision_Method' => 'applications/conduit/method/differential/createrevision',
|
||||
'ConduitAPI_differential_find_Method' => 'applications/conduit/method/differential/find',
|
||||
|
@ -819,6 +820,7 @@ phutil_register_library_map(array(
|
|||
'ConduitAPI_conduit_ping_Method' => 'ConduitAPIMethod',
|
||||
'ConduitAPI_daemon_launched_Method' => 'ConduitAPIMethod',
|
||||
'ConduitAPI_daemon_log_Method' => 'ConduitAPIMethod',
|
||||
'ConduitAPI_differential_createcomment_Method' => 'ConduitAPIMethod',
|
||||
'ConduitAPI_differential_creatediff_Method' => 'ConduitAPIMethod',
|
||||
'ConduitAPI_differential_createrevision_Method' => 'ConduitAPIMethod',
|
||||
'ConduitAPI_differential_find_Method' => 'ConduitAPIMethod',
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2011 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @group conduit
|
||||
*/
|
||||
class ConduitAPI_differential_createcomment_Method extends ConduitAPIMethod {
|
||||
|
||||
public function getMethodDescription() {
|
||||
return "Add a comment to a Differential revision.";
|
||||
}
|
||||
|
||||
public function defineParamTypes() {
|
||||
return array(
|
||||
'revision_id' => 'required revisionid',
|
||||
'message' => 'required string',
|
||||
);
|
||||
}
|
||||
|
||||
public function defineReturnType() {
|
||||
return 'nonempty dict';
|
||||
}
|
||||
|
||||
public function defineErrorTypes() {
|
||||
return array(
|
||||
'ERR_BAD_REVISION' => 'Bad revision ID.',
|
||||
);
|
||||
}
|
||||
|
||||
protected function execute(ConduitAPIRequest $request) {
|
||||
$revision = id(new DifferentialRevision())->load(
|
||||
$request->getValue('revision_id'));
|
||||
if (!$revision) {
|
||||
throw new ConduitException('ERR_BAD_REVISION');
|
||||
}
|
||||
|
||||
$content_source = PhabricatorContentSource::newForSource(
|
||||
PhabricatorContentSource::SOURCE_CONDUIT,
|
||||
array());
|
||||
|
||||
$editor = new DifferentialCommentEditor(
|
||||
$revision,
|
||||
$request->getUser()->getPHID(),
|
||||
DifferentialAction::ACTION_COMMENT);
|
||||
$editor->setContentSource($content_source);
|
||||
$editor->setMessage($request->getValue('message'));
|
||||
$editor->save();
|
||||
|
||||
return array(
|
||||
'revisionid' => $revision->getID(),
|
||||
'uri' => PhabricatorEnv::getURI('/D'.$revision->getID()),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is automatically generated. Lint this module to rebuild it.
|
||||
* @generated
|
||||
*/
|
||||
|
||||
|
||||
|
||||
phutil_require_module('phabricator', 'applications/conduit/method/base');
|
||||
phutil_require_module('phabricator', 'applications/conduit/protocol/exception');
|
||||
phutil_require_module('phabricator', 'applications/differential/constants/action');
|
||||
phutil_require_module('phabricator', 'applications/differential/editor/comment');
|
||||
phutil_require_module('phabricator', 'applications/differential/storage/revision');
|
||||
phutil_require_module('phabricator', 'applications/metamta/contentsource/source');
|
||||
phutil_require_module('phabricator', 'infrastructure/env');
|
||||
|
||||
phutil_require_module('phutil', 'utils');
|
||||
|
||||
|
||||
phutil_require_source('ConduitAPI_differential_createcomment_Method.php');
|
Loading…
Reference in a new issue