blob: 2adcbf5e5ce9da591524c12e7063cbd3ed559497 (
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
|
# Base class for Chat services
class MattermostChatService < ChatService
def title
'Mattermost'
end
def description
'Self-hosted Slack-alternative'
end
def to_param
'mattermost'
end
def help
'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,
and enter the token below.'
end
def fields
[
{ type: 'text', name: 'token', placeholder: 'https://hooks.slack.com/services/...' }
]
end
def trigger(params)
user = ChatNames::FindUserService.new(chat_names, params).execute
return authorize_chat_name(params) unless user
Mattermost::CommandService.new(project, user, params).execute
end
private
def authorize_chat_name(params)
url = ChatNames::RequestService.new(service, params).execute
{
response_type: :ephemeral,
message: "You are not authorized. Click this [link](#{url}) to authorize."
}
end
end
|