2018-12-05 23:21:45 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-08-24 12:49:21 +05:30
|
|
|
module ServiceParams
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
ALLOWED_PARAMS_CE = [
|
|
|
|
:active,
|
|
|
|
:add_pusher,
|
2020-06-23 00:09:42 +05:30
|
|
|
:alert_events,
|
2017-08-17 22:00:37 +05:30
|
|
|
:api_key,
|
|
|
|
:api_url,
|
|
|
|
:api_version,
|
|
|
|
:bamboo_url,
|
2019-12-04 20:38:33 +05:30
|
|
|
:branches_to_be_notified,
|
2017-08-17 22:00:37 +05:30
|
|
|
:build_key,
|
|
|
|
:build_type,
|
|
|
|
:ca_pem,
|
|
|
|
:channel,
|
|
|
|
:channels,
|
|
|
|
:color,
|
|
|
|
:colorize_messages,
|
2020-01-01 13:55:28 +05:30
|
|
|
:comment_on_event_enabled,
|
2020-05-24 23:13:21 +05:30
|
|
|
:comment_detail,
|
2017-08-17 22:00:37 +05:30
|
|
|
:confidential_issues_events,
|
2020-07-28 23:09:34 +05:30
|
|
|
:confluence_url,
|
2017-08-17 22:00:37 +05:30
|
|
|
:default_irc_uri,
|
|
|
|
:device,
|
|
|
|
:disable_diffs,
|
|
|
|
:drone_url,
|
|
|
|
:enable_ssl_verification,
|
|
|
|
:external_wiki_url,
|
2020-06-23 00:09:42 +05:30
|
|
|
:google_iap_service_account_json,
|
|
|
|
:google_iap_audience_client_id,
|
2020-07-28 23:09:34 +05:30
|
|
|
:inherit_from_id,
|
2017-08-17 22:00:37 +05:30
|
|
|
# We're using `issues_events` and `merge_requests_events`
|
|
|
|
# in the view so we still need to explicitly state them
|
|
|
|
# here. `Service#event_names` would only give
|
|
|
|
# `issue_events` and `merge_request_events` (singular!)
|
|
|
|
# See app/helpers/services_helper.rb for how we
|
|
|
|
# make those event names plural as special case.
|
|
|
|
:issues_events,
|
|
|
|
:issues_url,
|
|
|
|
:jira_issue_transition_id,
|
2018-03-17 18:26:18 +05:30
|
|
|
:manual_configuration,
|
2017-08-17 22:00:37 +05:30
|
|
|
:merge_requests_events,
|
|
|
|
:mock_service_url,
|
|
|
|
:namespace,
|
|
|
|
:new_issue_url,
|
|
|
|
:notify,
|
|
|
|
:notify_only_broken_pipelines,
|
|
|
|
:password,
|
|
|
|
:priority,
|
|
|
|
:project_key,
|
|
|
|
:project_url,
|
|
|
|
:recipients,
|
|
|
|
:restrict_to_branch,
|
|
|
|
:room,
|
|
|
|
:send_from_committer_email,
|
|
|
|
:server,
|
|
|
|
:server_host,
|
|
|
|
:server_port,
|
|
|
|
:sound,
|
|
|
|
:subdomain,
|
|
|
|
:teamcity_url,
|
|
|
|
:token,
|
|
|
|
:type,
|
|
|
|
:url,
|
|
|
|
:user_key,
|
|
|
|
:username,
|
|
|
|
:webhook
|
|
|
|
].freeze
|
2016-08-24 12:49:21 +05:30
|
|
|
|
|
|
|
# Parameters to ignore if no value is specified
|
2017-08-17 22:00:37 +05:30
|
|
|
FILTER_BLANK_PARAMS = [:password].freeze
|
2016-08-24 12:49:21 +05:30
|
|
|
|
|
|
|
def service_params
|
2018-03-17 18:26:18 +05:30
|
|
|
dynamic_params = @service.event_channel_names + @service.event_names # rubocop:disable Gitlab/ModuleWithInstanceVariables
|
2019-02-15 15:39:39 +05:30
|
|
|
service_params = params.permit(:id, service: allowed_service_params + dynamic_params)
|
2016-08-24 12:49:21 +05:30
|
|
|
|
2019-03-02 22:35:43 +05:30
|
|
|
if service_params[:service].is_a?(ActionController::Parameters)
|
2016-08-24 12:49:21 +05:30
|
|
|
FILTER_BLANK_PARAMS.each do |param|
|
|
|
|
service_params[:service].delete(param) if service_params[:service][param].blank?
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
service_params
|
|
|
|
end
|
2019-02-15 15:39:39 +05:30
|
|
|
|
|
|
|
def allowed_service_params
|
|
|
|
ALLOWED_PARAMS_CE
|
|
|
|
end
|
2016-08-24 12:49:21 +05:30
|
|
|
end
|
2019-12-04 20:38:33 +05:30
|
|
|
|
|
|
|
ServiceParams.prepend_if_ee('EE::ServiceParams')
|