summaryrefslogtreecommitdiff
path: root/lib/api
diff options
context:
space:
mode:
Diffstat (limited to 'lib/api')
-rw-r--r--lib/api/helpers.rb6
-rw-r--r--lib/api/notes.rb3
2 files changed, 9 insertions, 0 deletions
diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb
index 2aaa0557ea3..bae7f35a77d 100644
--- a/lib/api/helpers.rb
+++ b/lib/api/helpers.rb
@@ -281,6 +281,12 @@ module API
error!({ 'message' => message }, status)
end
+ def require_feature!(feature)
+ unless Gitlab::Feature.feature_enabled?(feature)
+ render_api_error!('503 Service Unavailable', 503)
+ end
+ end
+
# Projects helpers
def filter_projects(projects)
diff --git a/lib/api/notes.rb b/lib/api/notes.rb
index d4fcfd3d4d3..eeb7e87a3bd 100644
--- a/lib/api/notes.rb
+++ b/lib/api/notes.rb
@@ -71,6 +71,7 @@ module API
# POST /projects/:id/issues/:noteable_id/notes
# POST /projects/:id/snippets/:noteable_id/notes
post ":id/#{noteables_str}/:#{noteable_id_str}/notes" do
+ require_feature! :creating_notes
required_attributes! [:body]
opts = {
@@ -103,6 +104,7 @@ module API
# PUT /projects/:id/issues/:noteable_id/notes/:note_id
# PUT /projects/:id/snippets/:noteable_id/notes/:node_id
put ":id/#{noteables_str}/:#{noteable_id_str}/notes/:note_id" do
+ require_feature! :updating_notes
required_attributes! [:body]
note = user_project.notes.find(params[:note_id])
@@ -132,6 +134,7 @@ module API
# DELETE /projects/:id/issues/:noteable_id/notes/:note_id
# DELETE /projects/:id/snippets/:noteable_id/notes/:node_id
delete ":id/#{noteables_str}/:#{noteable_id_str}/notes/:note_id" do
+ require_feature! :removing_notes
note = user_project.notes.find(params[:note_id])
authorize! :admin_note, note