BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
7dd645e6
Commit
7dd645e6
authored
Apr 03, 2017
by
Tiago Botelho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add note message integration with microsoft teams
parent
efe2d96a
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
45 additions
and
36 deletions
+45
-36
base_message.rb
app/models/project_services/chat_message/base_message.rb
+1
-1
note_message.rb
app/models/project_services/chat_message/note_message.rb
+38
-26
push_message.rb
app/models/project_services/chat_message/push_message.rb
+4
-7
chat_notification_service.rb
app/models/project_services/chat_notification_service.rb
+1
-1
microsoft_teams_service.rb
app/models/project_services/microsoft_teams_service.rb
+1
-1
No files found.
app/models/project_services/chat_message/base_message.rb
View file @
7dd645e6
...
...
@@ -7,7 +7,7 @@ module ChatMessage
end
def
pretext
format
(
message
)
markdown_format
?
message
:
format
(
message
)
end
def
fallback
...
...
app/models/project_services/chat_message/note_message.rb
View file @
7dd645e6
module
ChatMessage
class
NoteMessage
<
BaseMessage
attr_reader
:message
attr_reader
:user_name
attr_reader
:user_avatar
attr_reader
:project_name
attr_reader
:project_url
attr_reader
:note
attr_reader
:note_url
attr_reader
:comment_attrs
attr_reader
:markdown_format
def
initialize
(
params
)
params
=
HashWithIndifferentAccess
.
new
(
params
)
@user_name
=
params
[
:user
][
:
user
name
]
@user_avatar
=
params
[
:user
][
:avatar
]
@user_name
=
params
[
:user
][
:name
]
@user_avatar
=
params
[
:user
][
:avatar
_url
]
@project_name
=
params
[
:project_name
]
@project_url
=
params
[
:project_url
]
...
...
@@ -18,7 +20,30 @@ module ChatMessage
obj_attr
=
HashWithIndifferentAccess
.
new
(
obj_attr
)
@note
=
obj_attr
[
:note
]
@note_url
=
obj_attr
[
:url
]
noteable_type
=
obj_attr
[
:noteable_type
]
@comment_attrs
=
comment_params
(
obj_attr
[
:noteable_type
],
params
)
@markdown_format
=
params
[
:format
]
end
def
activity
{
title:
"
#{
user_name
}
#{
link
(
'commented on '
+
comment_attrs
[
:target
],
note_url
)
}
"
,
subtitle:
"to:
#{
project_link
}
"
,
text:
"*
#{
comment_attrs
[
:title
]
}
*"
,
image:
user_avatar
}
end
def
attachments
markdown_format
?
note
:
description_message
end
private
def
message
commented_on_message
(
comment_attrs
)
end
def
comment_params
(
noteable_type
,
params
)
case
noteable_type
when
"Commit"
create_commit_note
(
HashWithIndifferentAccess
.
new
(
params
[
:commit
]))
...
...
@@ -31,40 +56,27 @@ module ChatMessage
end
end
def
attachments
description_message
end
private
def
format_title
(
title
)
title
.
lines
.
first
.
chomp
end
def
create_issue_note
(
issue
)
{
target:
"issue #
#{
issue
[
:iid
]
}
"
,
title:
format_title
(
issue
[
:title
])
}
end
def
create_commit_note
(
commit
)
commit_sha
=
commit
[
:id
]
commit_sha
=
Commit
.
truncate_sha
(
commit_sha
)
commented_on_message
(
"commit
#{
commit_sha
}
"
,
format_title
(
commit
[
:message
]))
end
def
create_issue_note
(
issue
)
commented_on_message
(
"issue #
#{
issue
[
:iid
]
}
"
,
format_title
(
issue
[
:title
]))
{
target:
"commit
#{
commit_sha
}
"
,
title:
format_title
(
commit
[
:message
])
}
end
def
create_merge_note
(
merge_request
)
commented_on_message
(
"merge request !
#{
merge_request
[
:iid
]
}
"
,
format_title
(
merge_request
[
:title
]))
{
target:
"merge request !
#{
merge_request
[
:iid
]
}
"
,
title:
format_title
(
merge_request
[
:title
])
}
end
def
create_snippet_note
(
snippet
)
commented_on_message
(
"snippet #
#{
snippet
[
:id
]
}
"
,
format_title
(
snippet
[
:title
]))
{
target:
"snippet #
#{
snippet
[
:id
]
}
"
,
title:
format_title
(
snippet
[
:title
])
}
end
def
description_message
...
...
@@ -75,8 +87,8 @@ module ChatMessage
link
(
project_name
,
project_url
)
end
def
commented_on_message
(
target
,
title
)
@message
=
"
#{
user_name
}
#{
link
(
'commented on '
+
target
,
note_url
)
}
in
#{
project_link
}
: *
#{
title
}
*"
def
commented_on_message
(
target
:,
title
:
)
"
#{
user_name
}
#{
link
(
'commented on '
+
target
,
note_url
)
}
in
#{
project_link
}
: *
#{
title
}
*"
end
end
end
app/models/project_services/chat_message/push_message.rb
View file @
7dd645e6
...
...
@@ -9,6 +9,7 @@ module ChatMessage
attr_reader
:ref_type
attr_reader
:user_name
attr_reader
:user_avatar
attr_reader
:markdown_format
def
initialize
(
params
)
@after
=
params
[
:after
]
...
...
@@ -20,7 +21,7 @@ module ChatMessage
@ref
=
Gitlab
::
Git
.
ref_name
(
params
[
:ref
])
@user_name
=
params
[
:user_name
]
@user_avatar
=
params
[
:user_avatar
]
@format
=
params
[
:format
]
@
markdown_
format
=
params
[
:format
]
end
def
activity
...
...
@@ -28,18 +29,14 @@ module ChatMessage
title:
activity_title
,
subtitle:
"to:
#{
project_link
}
"
,
text:
compare_link
,
image:
params
[
:user_avatar
]
image:
user_avatar
}
end
def
pretext
@format
?
format
(
message
)
:
message
end
def
attachments
return
[]
if
new_branch?
||
removed_branch?
@format
?
commit_message_attachments
:
commit_message
s
markdown_format
?
commit_messages
:
commit_message_attachment
s
end
private
...
...
app/models/project_services/chat_notification_service.rb
View file @
7dd645e6
...
...
@@ -52,7 +52,7 @@ class ChatNotificationService < Service
data
=
data
.
merge
(
project_url:
project_url
,
project_name:
project_name
,
format:
tru
e
format:
fals
e
)
# WebHook events often have an 'update' event that follows a 'open' or
...
...
app/models/project_services/microsoft_teams_service.rb
View file @
7dd645e6
...
...
@@ -50,7 +50,7 @@ class MicrosoftTeamsService < ChatNotificationService
data
=
data
.
merge
(
project_url:
project_url
,
project_name:
project_name
,
format:
fals
e
format:
tru
e
)
message
=
get_message
(
object_kind
,
data
)
...
...
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