2016-11-13 19:35:47 +00:00
|
|
|
class MattermostChatService < ChatService
|
2016-11-14 14:10:35 +00:00
|
|
|
include TriggersHelper
|
|
|
|
|
|
|
|
prop_accessor :token
|
|
|
|
|
|
|
|
def can_test?
|
|
|
|
false
|
|
|
|
end
|
|
|
|
|
2016-11-13 19:35:47 +00:00
|
|
|
def title
|
|
|
|
'Mattermost'
|
|
|
|
end
|
|
|
|
|
|
|
|
def description
|
2016-11-14 11:41:14 +00:00
|
|
|
'Mattermost is an open source, self-hosted Slack-alternative'
|
2016-11-13 19:35:47 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def to_param
|
|
|
|
'mattermost'
|
|
|
|
end
|
|
|
|
|
|
|
|
def help
|
2016-11-14 14:10:35 +00:00
|
|
|
"This service allows you to use slash commands with your Mattermost installation.<br/>
|
|
|
|
To setup this Service you need to create a new <b>Slash commands</b> in your Mattermost integration panel.<br/>
|
|
|
|
<br/>
|
|
|
|
Create integration with URL #{service_trigger_url(self)} and enter the token below."
|
2016-11-13 19:35:47 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def fields
|
|
|
|
[
|
2016-11-14 14:10:35 +00:00
|
|
|
{ type: 'text', name: 'token', placeholder: '' }
|
2016-11-13 19:35:47 +00:00
|
|
|
]
|
|
|
|
end
|
|
|
|
|
|
|
|
def trigger(params)
|
2016-11-15 08:55:56 +00:00
|
|
|
user = ChatNames::FindUserService.new(chat_names, params).execute
|
|
|
|
return Mattermost::Presenter.authorize_chat_name(params) unless user
|
2016-11-13 19:35:47 +00:00
|
|
|
|
2016-11-14 14:10:35 +00:00
|
|
|
Mattermost::CommandService.new(project, user, params.slice(:command, :text)).
|
|
|
|
execute
|
2016-11-13 19:35:47 +00:00
|
|
|
end
|
|
|
|
end
|