From d31accf0768d7adbcdedca0a6734481aaef50307 Mon Sep 17 00:00:00 2001 From: Alan Huang Date: Thu, 2 Aug 2012 12:25:01 -0700 Subject: [PATCH] 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 --- src/__phutil_library_map__.php | 2 + .../flag/ConduitAPI_flag_delete_Method.php | 58 +++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 src/applications/conduit/method/flag/ConduitAPI_flag_delete_Method.php 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; + } + +}