Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib/api
diff options
context:
space:
mode:
Diffstat (limited to 'lib/api')
-rw-r--r--lib/api/broadcast_messages.rb9
-rw-r--r--lib/api/helpers/internal_helpers.rb14
2 files changed, 12 insertions, 11 deletions
diff --git a/lib/api/broadcast_messages.rb b/lib/api/broadcast_messages.rb
index 994e12445b7..48d4f1a0a63 100644
--- a/lib/api/broadcast_messages.rb
+++ b/lib/api/broadcast_messages.rb
@@ -4,9 +4,6 @@ module API
class BroadcastMessages < Grape::API
include PaginationParams
- before { authenticate! }
- before { authenticated_as_admin! }
-
resource :broadcast_messages do
helpers do
def find_message
@@ -40,6 +37,8 @@ module API
optional :target_path, type: String, desc: 'Target path'
end
post do
+ authenticated_as_admin!
+
message = BroadcastMessage.create(declared_params(include_missing: false))
if message.persisted?
@@ -76,6 +75,8 @@ module API
optional :target_path, type: String, desc: 'Target path'
end
put ':id' do
+ authenticated_as_admin!
+
message = find_message
if message.update(declared_params(include_missing: false))
@@ -93,6 +94,8 @@ module API
requires :id, type: Integer, desc: 'Broadcast message ID'
end
delete ':id' do
+ authenticated_as_admin!
+
message = find_message
destroy_conditionally!(message)
diff --git a/lib/api/helpers/internal_helpers.rb b/lib/api/helpers/internal_helpers.rb
index c8e96c7c5db..cc9d45dcae4 100644
--- a/lib/api/helpers/internal_helpers.rb
+++ b/lib/api/helpers/internal_helpers.rb
@@ -104,14 +104,12 @@ module API
# rubocop:disable Gitlab/ModuleWithInstanceVariables
def set_project
- if params[:gl_repository]
- @project, @repo_type = Gitlab::GlRepository.parse(params[:gl_repository])
- @redirected_path = nil
- elsif params[:project]
- @project, @repo_type, @redirected_path = Gitlab::RepoPath.parse(params[:project])
- else
- @project, @repo_type, @redirected_path = nil, nil, nil
- end
+ @project, @repo_type, @redirected_path =
+ if params[:gl_repository]
+ Gitlab::GlRepository.parse(params[:gl_repository])
+ elsif params[:project]
+ Gitlab::RepoPath.parse(params[:project])
+ end
end
# rubocop:enable Gitlab/ModuleWithInstanceVariables