Commit 6195ab75 authored by Rémy Coutable's avatar Rémy Coutable

Refactor allowed params in ServiceParams

Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent bf073583
module ServiceParams module ServiceParams
extend ActiveSupport::Concern extend ActiveSupport::Concern
ALLOWED_PARAMS = [:title, :token, :type, :active, :api_key, :api_url, :api_version, :subdomain, ALLOWED_PARAMS_CE = [
:room, :recipients, :project_url, :webhook, :active,
:user_key, :device, :priority, :sound, :bamboo_url, :username, :password, :add_pusher,
:build_key, :server, :teamcity_url, :drone_url, :build_type, :api_key,
:description, :issues_url, :new_issue_url, :restrict_to_branch, :channel, :api_url,
:colorize_messages, :channels, :api_version,
# We're using `issues_events` and `merge_requests_events` :bamboo_url,
# in the view so we still need to explicitly state them :build_key,
# here. `Service#event_names` would only give :build_type,
# `issue_events` and `merge_request_events` (singular!) :ca_pem,
# See app/helpers/services_helper.rb for how we :channel,
# make those event names plural as special case. :channels,
:issues_events, :confidential_issues_events, :merge_requests_events, :color,
:notify_only_broken_builds, :notify_only_broken_pipelines, :colorize_messages,
:add_pusher, :send_from_committer_email, :disable_diffs, :confidential_issues_events,
:external_wiki_url, :notify, :color, :default_irc_uri,
:server_host, :server_port, :default_irc_uri, :enable_ssl_verification, :description,
:jira_issue_transition_id, :url, :project_key, :ca_pem, :namespace] :device,
:disable_diffs,
:drone_url,
:enable_ssl_verification,
:external_wiki_url,
# 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,
:merge_requests_events,
:namespace,
:new_issue_url,
:notify,
:notify_only_broken_builds,
: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,
:title,
:token,
:type,
:url,
:user_key,
:username,
:webhook
]
# Parameters to ignore if no value is specified # Parameters to ignore if no value is specified
FILTER_BLANK_PARAMS = [:password] FILTER_BLANK_PARAMS = [:password]
def service_params def service_params
dynamic_params = @service.event_channel_names + @service.event_names dynamic_params = @service.event_channel_names + @service.event_names
service_params = params.permit(:id, service: ALLOWED_PARAMS + dynamic_params) service_params = params.permit(:id, service: ALLOWED_PARAMS_CE + dynamic_params)
if service_params[:service].is_a?(Hash) if service_params[:service].is_a?(Hash)
FILTER_BLANK_PARAMS.each do |param| FILTER_BLANK_PARAMS.each do |param|
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment