blob: ebba20b285ae25722061273de7f4e5b15d06069a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# 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)
if result
flash[:notice] = 'This service is now configured'
redirect_to edit_project_service_path(@project, integration)
else
flash[:alert] = message || 'Failed to configure service'
redirect_to new_project_mattermost_path(@project)
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
|