2016-07-12 16:00:49 -04:00
|
|
|
module ServiceParams
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
ALLOWED_PARAMS = [:title, :token, :type, :active, :api_key, :api_url, :api_version, :subdomain,
|
|
|
|
:room, :recipients, :project_url, :webhook,
|
|
|
|
:user_key, :device, :priority, :sound, :bamboo_url, :username, :password,
|
|
|
|
:build_key, :server, :teamcity_url, :drone_url, :build_type,
|
|
|
|
:description, :issues_url, :new_issue_url, :restrict_to_branch, :channel,
|
|
|
|
:colorize_messages, :channels,
|
2016-08-02 06:06:31 -04:00
|
|
|
# See app/helpers/services_helper.rb
|
|
|
|
# for why we need issues_events and merge_requests_events.
|
|
|
|
:issues_events, :merge_requests_events,
|
|
|
|
:notify_only_broken_builds, :notify_only_broken_pipelines,
|
|
|
|
:add_pusher, :send_from_committer_email, :disable_diffs,
|
|
|
|
:external_wiki_url, :notify, :color,
|
2016-07-12 16:00:49 -04:00
|
|
|
:server_host, :server_port, :default_irc_uri, :enable_ssl_verification,
|
|
|
|
:jira_issue_transition_id]
|
|
|
|
|
|
|
|
# Parameters to ignore if no value is specified
|
|
|
|
FILTER_BLANK_PARAMS = [:password]
|
|
|
|
|
2016-07-13 15:49:47 -04:00
|
|
|
def service_params
|
2016-08-02 06:06:31 -04:00
|
|
|
dynamic_params = @service.event_channel_names + @service.event_names
|
2016-07-13 15:49:47 -04:00
|
|
|
service_params = params.permit(:id, service: ALLOWED_PARAMS + dynamic_params)
|
2016-07-12 16:00:49 -04:00
|
|
|
|
2016-07-13 15:49:47 -04:00
|
|
|
if service_params[:service].is_a?(Hash)
|
2016-07-12 16:00:49 -04:00
|
|
|
FILTER_BLANK_PARAMS.each do |param|
|
2016-07-13 15:49:47 -04:00
|
|
|
service_params[:service].delete(param) if service_params[:service][param].blank?
|
2016-07-12 16:00:49 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-07-13 15:49:47 -04:00
|
|
|
service_params
|
2016-07-12 16:00:49 -04:00
|
|
|
end
|
|
|
|
end
|