diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-23 12:09:47 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-23 12:09:47 +0000 |
commit | 8f9beefac3774b30e911fb00a68f4c7a5244cf27 (patch) | |
tree | 919c3a043f8c10bc3f78f3f6e029acfb6b972556 /lib/api | |
parent | e4bf776a8829e5186a0f63603c0be627b891d80e (diff) | |
download | gitlab-ce-8f9beefac3774b30e911fb00a68f4c7a5244cf27.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/api')
-rw-r--r-- | lib/api/entities/note.rb | 8 | ||||
-rw-r--r-- | lib/api/helpers.rb | 1 | ||||
-rw-r--r-- | lib/api/helpers/notes_helpers.rb | 5 | ||||
-rw-r--r-- | lib/api/notes.rb | 6 | ||||
-rw-r--r-- | lib/api/projects.rb | 1 |
5 files changed, 20 insertions, 1 deletions
diff --git a/lib/api/entities/note.rb b/lib/api/entities/note.rb index dcfb9a6d670..4d140454ff0 100644 --- a/lib/api/entities/note.rb +++ b/lib/api/entities/note.rb @@ -25,6 +25,14 @@ module API # Avoid N+1 queries as much as possible expose(:noteable_iid) { |note| note.noteable.iid if NOTEABLE_TYPES_WITH_IID.include?(note.noteable_type) } + + expose(:commands_changes) { |note| note.commands_changes || {} } + end + + # To be returned if the note was command-only + class NoteCommands < Grape::Entity + expose(:commands_changes) { |note| note.commands_changes || {} } + expose(:summary) { |note| note.errors[:commands_only] } end end end diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb index c3b5654e217..47784dc771e 100644 --- a/lib/api/helpers.rb +++ b/lib/api/helpers.rb @@ -505,6 +505,7 @@ module API finder_params[:visibility_level] = Gitlab::VisibilityLevel.level_value(params[:visibility]) if params[:visibility] finder_params[:archived] = archived_param unless params[:archived].nil? finder_params[:search] = params[:search] if params[:search] + finder_params[:search_namespaces] = true if params[:search_namespaces].present? finder_params[:user] = params.delete(:user) if params[:user] finder_params[:custom_attributes] = params[:custom_attributes] if params[:custom_attributes] finder_params[:min_access_level] = params[:min_access_level] if params[:min_access_level] diff --git a/lib/api/helpers/notes_helpers.rb b/lib/api/helpers/notes_helpers.rb index bed0345a608..c85a38fc18b 100644 --- a/lib/api/helpers/notes_helpers.rb +++ b/lib/api/helpers/notes_helpers.rb @@ -113,6 +113,7 @@ module API end def create_note(noteable, opts) + whitelist_query_limiting authorize!(:create_note, noteable) parent = noteable_parent(noteable) @@ -139,6 +140,10 @@ module API present discussion, with: Entities::Discussion end + + def whitelist_query_limiting + Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab/-/issues/211538') + end end end end diff --git a/lib/api/notes.rb b/lib/api/notes.rb index 7237fa24bab..3eafc1ead77 100644 --- a/lib/api/notes.rb +++ b/lib/api/notes.rb @@ -82,9 +82,13 @@ module API note = create_note(noteable, opts) - if note.valid? + if note.errors.keys == [:commands_only] + status 202 + present note, with: Entities::NoteCommands + elsif note.valid? present note, with: Entities.const_get(note.class.name, false) else + note.errors.delete(:commands_only) if note.errors.has_key?(:commands) bad_request!("Note #{note.errors.messages}") end end diff --git a/lib/api/projects.rb b/lib/api/projects.rb index 3717e25d997..a33418c3336 100644 --- a/lib/api/projects.rb +++ b/lib/api/projects.rb @@ -63,6 +63,7 @@ module API optional :visibility, type: String, values: Gitlab::VisibilityLevel.string_values, desc: 'Limit by visibility' optional :search, type: String, desc: 'Return list of projects matching the search criteria' + optional :search_namespaces, type: Boolean, desc: "Include ancestor namespaces when matching search criteria" optional :owned, type: Boolean, default: false, desc: 'Limit by owned by authenticated user' optional :starred, type: Boolean, default: false, desc: 'Limit by starred status' optional :membership, type: Boolean, default: false, desc: 'Limit by projects that the current user is a member of' |