mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-23 13:08:18 +01:00
Add a flag.delete Conduit method
Summary: Fairly straightforward: allow deletion of flags from Conduit. Test Plan: Try arc call-conduit with different ids. Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Maniphest Tasks: T1556 Differential Revision: https://secure.phabricator.com/D3132
This commit is contained in:
parent
8e5189b439
commit
d31accf076
2 changed files with 60 additions and 0 deletions
|
@ -145,6 +145,7 @@ phutil_register_library_map(array(
|
|||
'ConduitAPI_file_info_Method' => 'applications/conduit/method/file/ConduitAPI_file_info_Method.php',
|
||||
'ConduitAPI_file_upload_Method' => 'applications/conduit/method/file/ConduitAPI_file_upload_Method.php',
|
||||
'ConduitAPI_flag_Method' => 'applications/conduit/method/flag/ConduitAPI_flag_Method.php',
|
||||
'ConduitAPI_flag_delete_Method' => 'applications/conduit/method/flag/ConduitAPI_flag_delete_Method.php',
|
||||
'ConduitAPI_flag_query_Method' => 'applications/conduit/method/flag/ConduitAPI_flag_query_Method.php',
|
||||
'ConduitAPI_macro_Method' => 'applications/conduit/method/macro/ConduitAPI_macro_Method.php',
|
||||
'ConduitAPI_macro_query_Method' => 'applications/conduit/method/macro/ConduitAPI_macro_query_Method.php',
|
||||
|
@ -1263,6 +1264,7 @@ phutil_register_library_map(array(
|
|||
'ConduitAPI_file_info_Method' => 'ConduitAPIMethod',
|
||||
'ConduitAPI_file_upload_Method' => 'ConduitAPIMethod',
|
||||
'ConduitAPI_flag_Method' => 'ConduitAPIMethod',
|
||||
'ConduitAPI_flag_delete_Method' => 'ConduitAPI_flag_Method',
|
||||
'ConduitAPI_flag_query_Method' => 'ConduitAPI_flag_Method',
|
||||
'ConduitAPI_macro_Method' => 'ConduitAPIMethod',
|
||||
'ConduitAPI_macro_query_Method' => 'ConduitAPI_macro_Method',
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2012 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
|
||||
*/
|
||||
final class ConduitAPI_flag_delete_Method extends ConduitAPI_flag_Method {
|
||||
|
||||
public function getMethodDescription() {
|
||||
return "Clear a flag.";
|
||||
}
|
||||
|
||||
public function defineParamTypes() {
|
||||
return array(
|
||||
'id' => 'required id',
|
||||
);
|
||||
}
|
||||
|
||||
public function defineReturnType() {
|
||||
return 'void';
|
||||
}
|
||||
|
||||
public function defineErrorTypes() {
|
||||
return array(
|
||||
'ERR_NOT_FOUND' => 'Bad flag ID.',
|
||||
'ERR_WRONG_USER' => 'You are not the creator of this flag.',
|
||||
);
|
||||
}
|
||||
|
||||
protected function execute(ConduitAPIRequest $request) {
|
||||
$id = $request->getValue('id');
|
||||
$flag = id(new PhabricatorFlag())->load($id);
|
||||
if (!$flag) {
|
||||
throw new ConduitException('ERR_NOT_FOUND');
|
||||
}
|
||||
if ($flag->getOwnerPHID() != $request->getUser()->getPHID()) {
|
||||
throw new ConduitException('ERR_WRONG_USER');
|
||||
}
|
||||
$flag->delete();
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue