gitlab-org--gitlab-foss/app/controllers/projects/mattermosts_controller.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

46 lines
1.2 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
class Projects::MattermostsController < Projects::ApplicationController
include Ci::TriggersHelper
include ActionView::Helpers::AssetUrlHelper
layout 'project_settings'
before_action :authorize_admin_project!
before_action :integration
before_action :teams, only: [:new]
feature_category :integrations
def new
end
def create
result, message = integration.configure(current_user, configure_params)
2016-12-20 13:11:53 -05:00
if result
flash[:notice] = 'This service is now configured'
redirect_to edit_project_settings_integration_path(@project, integration)
2016-12-20 13:11:53 -05:00
else
flash[:alert] = message || 'Failed to configure service'
redirect_to new_project_mattermost_path(@project)
2016-12-20 13:11:53 -05:00
end
end
private
def configure_params
params.require(:mattermost).permit(:trigger, :team_id).merge(
url: service_trigger_url(integration),
icon_url: asset_url('slash-command-logo.png', skip_pipeline: true))
end
def teams
@teams, @teams_error_message = integration.list_teams(current_user)
end
def integration
@integration ||= @project.find_or_initialize_integration('mattermost_slash_commands')
end
end