Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
gitlab-ce
Commits
9191f538
Commit
9191f538
authored
Nov 13, 2016
by
Kamil Trzcinski
Committed by
Z.J. van de Weg
Nov 17, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create relation between chat user and GitLab user and allow to authorize them [ci skip]
parent
242e291e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
65 additions
and
0 deletions
+65
-0
app/models/project_services/chat_service.rb
app/models/project_services/chat_service.rb
+21
-0
app/models/project_services/mattermost_chat_service.rb
app/models/project_services/mattermost_chat_service.rb
+44
-0
No files found.
app/models/project_services/chat_service.rb
0 → 100644
View file @
9191f538
# Base class for Chat services
class
ChatService
<
Service
default_value_for
:category
,
'chat'
has_many
:chat_users
def
valid_token?
(
token
)
self
.
respond_to?
(
:token
)
&&
self
.
token
.
present?
&&
ActiveSupport
::
SecurityUtils
.
variable_size_secure_compare
(
token
,
self
.
token
)
end
def
supported_events
end
def
trigger
(
params
)
# implement inside child
end
def
chat_user_params
(
params
)
params
.
permit
()
end
end
app/models/project_services/mattermost_chat_service.rb
0 → 100644
View file @
9191f538
# 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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment