summaryrefslogtreecommitdiff
path: root/app/services
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-04-07 15:09:30 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-04-07 15:09:30 +0000
commitc6b3ec3f56fa32a0e0ed3de0d0878d25f1adaddf (patch)
tree967afee9a510ff9dd503ebd83706dc760ec2e3ed /app/services
parent903ccf7c93eb9490c76857bffe744249cc07de09 (diff)
downloadgitlab-ce-c6b3ec3f56fa32a0e0ed3de0d0878d25f1adaddf.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/services')
-rw-r--r--app/services/members/update_highest_role_service.rb39
-rw-r--r--app/services/projects/alerting/notify_service.rb6
-rw-r--r--app/services/projects/import_export/export_service.rb7
-rw-r--r--app/services/projects/prometheus/alerts/notify_service.rb20
4 files changed, 20 insertions, 52 deletions
diff --git a/app/services/members/update_highest_role_service.rb b/app/services/members/update_highest_role_service.rb
deleted file mode 100644
index 5ebd2e03df1..00000000000
--- a/app/services/members/update_highest_role_service.rb
+++ /dev/null
@@ -1,39 +0,0 @@
-# frozen_string_literal: true
-
-module Members
- class UpdateHighestRoleService < ::BaseService
- include ExclusiveLeaseGuard
-
- LEASE_TIMEOUT = 10.minutes.to_i
- DELAY = 10.minutes
-
- attr_reader :user_id
-
- def initialize(user_id)
- @user_id = user_id
- end
-
- def execute
- try_obtain_lease do
- UpdateHighestRoleWorker.perform_in(DELAY, user_id)
- end
- end
-
- private
-
- def lease_key
- "update_highest_role:#{user_id}"
- end
-
- def lease_timeout
- LEASE_TIMEOUT
- end
-
- # Do not release the lease before the timeout to
- # prevent multiple jobs being executed during the
- # defined timeout
- def lease_release?
- false
- end
- end
-end
diff --git a/app/services/projects/alerting/notify_service.rb b/app/services/projects/alerting/notify_service.rb
index d34d6f6a915..1ce1ef7a1cd 100644
--- a/app/services/projects/alerting/notify_service.rb
+++ b/app/services/projects/alerting/notify_service.rb
@@ -46,15 +46,15 @@ module Projects
end
def bad_request
- ServiceResponse.error(message: 'Bad Request', http_status: 400)
+ ServiceResponse.error(message: 'Bad Request', http_status: :bad_request)
end
def unauthorized
- ServiceResponse.error(message: 'Unauthorized', http_status: 401)
+ ServiceResponse.error(message: 'Unauthorized', http_status: :unauthorized)
end
def forbidden
- ServiceResponse.error(message: 'Forbidden', http_status: 403)
+ ServiceResponse.error(message: 'Forbidden', http_status: :forbidden)
end
end
end
diff --git a/app/services/projects/import_export/export_service.rb b/app/services/projects/import_export/export_service.rb
index fa098e7417c..8893bf18e1f 100644
--- a/app/services/projects/import_export/export_service.rb
+++ b/app/services/projects/import_export/export_service.rb
@@ -58,12 +58,7 @@ module Projects
end
def tree_saver_class
- if ::Feature.enabled?(:streaming_serializer, project, default_enabled: true)
- Gitlab::ImportExport::Project::TreeSaver
- else
- # Once we remove :streaming_serializer feature flag, Project::LegacyTreeSaver should be removed as well
- Gitlab::ImportExport::Project::LegacyTreeSaver
- end
+ Gitlab::ImportExport::Project::TreeSaver
end
def uploads_saver
diff --git a/app/services/projects/prometheus/alerts/notify_service.rb b/app/services/projects/prometheus/alerts/notify_service.rb
index 89791aecabb..6ebc061c2e3 100644
--- a/app/services/projects/prometheus/alerts/notify_service.rb
+++ b/app/services/projects/prometheus/alerts/notify_service.rb
@@ -8,15 +8,15 @@ module Projects
include IncidentManagement::Settings
def execute(token)
- return false unless valid_payload_size?
- return false unless valid_version?
- return false unless valid_alert_manager_token?(token)
+ return bad_request unless valid_payload_size?
+ return unprocessable_entity unless valid_version?
+ return unauthorized unless valid_alert_manager_token?(token)
persist_events
send_alert_email if send_email?
process_incident_issues if process_issues?
- true
+ ServiceResponse.success
end
private
@@ -118,6 +118,18 @@ module Projects
def persist_events
CreateEventsService.new(project, nil, params).execute
end
+
+ def bad_request
+ ServiceResponse.error(message: 'Bad Request', http_status: :bad_request)
+ end
+
+ def unauthorized
+ ServiceResponse.error(message: 'Unauthorized', http_status: :unauthorized)
+ end
+
+ def unprocessable_entity
+ ServiceResponse.error(message: 'Unprocessable Entity', http_status: :unprocessable_entity)
+ end
end
end
end