diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 0f5eeb3e70..adc3122af6 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -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', diff --git a/src/applications/conduit/method/flag/ConduitAPI_flag_delete_Method.php b/src/applications/conduit/method/flag/ConduitAPI_flag_delete_Method.php new file mode 100644 index 0000000000..610c129ec8 --- /dev/null +++ b/src/applications/conduit/method/flag/ConduitAPI_flag_delete_Method.php @@ -0,0 +1,58 @@ + '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; + } + +}