gitlab-org--gitlab-foss/app/models/project_services/mattermost_slash_commands_s...

48 lines
981 B
Ruby
Raw Normal View History

2016-12-16 13:21:06 +00:00
class MattermostSlashCommandsService < ChatSlashCommandsService
include TriggersHelper
prop_accessor :token
def can_test?
false
end
def title
'Mattermost Command'
end
def description
2016-11-18 12:29:47 +00:00
"Perform common operations on GitLab in Mattermost"
end
def to_param
'mattermost_slash_commands'
end
2016-12-19 23:22:10 +00:00
def configure!(user, params)
token = Mattermost::Command.new(user).
create(command(params))
update!(active: true, token: token)
end
def list_teams(user)
2016-12-19 23:22:10 +00:00
Mattermost::Team.new(user).all
end
private
def command(params)
2016-12-16 19:29:17 +00:00
pretty_project_name = project.name_with_namespace
params.merge(
2016-12-16 19:29:17 +00:00
auto_complete: true,
auto_complete_desc: "Perform common operations on: #{pretty_project_name}",
auto_complete_hint: '[help]',
description: "Perform common operations on: #{pretty_project_name}",
display_name: "GitLab / #{pretty_project_name}",
method: 'P',
user_name: 'GitLab')
2016-12-16 19:29:17 +00:00
end
end