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
1
Merge Requests
1
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
nexedi
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
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
45 additions
and
36 deletions
+45
-36
app/models/project_services/chat_message/base_message.rb
app/models/project_services/chat_message/base_message.rb
+1
-1
app/models/project_services/chat_message/note_message.rb
app/models/project_services/chat_message/note_message.rb
+38
-26
app/models/project_services/chat_message/push_message.rb
app/models/project_services/chat_message/push_message.rb
+4
-7
app/models/project_services/chat_notification_service.rb
app/models/project_services/chat_notification_service.rb
+1
-1
app/models/project_services/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
...
@@ -7,7 +7,7 @@ module ChatMessage
end
end
def
pretext
def
pretext
format
(
message
)
markdown_format
?
message
:
format
(
message
)
end
end
def
fallback
def
fallback
...
...
app/models/project_services/chat_message/note_message.rb
View file @
7dd645e6
module
ChatMessage
module
ChatMessage
class
NoteMessage
<
BaseMessage
class
NoteMessage
<
BaseMessage
attr_reader
:message
attr_reader
:user_name
attr_reader
:user_name
attr_reader
:user_avatar
attr_reader
:project_name
attr_reader
:project_name
attr_reader
:project_url
attr_reader
:project_url
attr_reader
:note
attr_reader
:note
attr_reader
:note_url
attr_reader
:note_url
attr_reader
:comment_attrs
attr_reader
:markdown_format
def
initialize
(
params
)
def
initialize
(
params
)
params
=
HashWithIndifferentAccess
.
new
(
params
)
params
=
HashWithIndifferentAccess
.
new
(
params
)
@user_name
=
params
[
:user
][
:
user
name
]
@user_name
=
params
[
:user
][
:name
]
@user_avatar
=
params
[
:user
][
:avatar
]
@user_avatar
=
params
[
:user
][
:avatar
_url
]
@project_name
=
params
[
:project_name
]
@project_name
=
params
[
:project_name
]
@project_url
=
params
[
:project_url
]
@project_url
=
params
[
:project_url
]
...
@@ -18,7 +20,30 @@ module ChatMessage
...
@@ -18,7 +20,30 @@ module ChatMessage
obj_attr
=
HashWithIndifferentAccess
.
new
(
obj_attr
)
obj_attr
=
HashWithIndifferentAccess
.
new
(
obj_attr
)
@note
=
obj_attr
[
:note
]
@note
=
obj_attr
[
:note
]
@note_url
=
obj_attr
[
:url
]
@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
case
noteable_type
when
"Commit"
when
"Commit"
create_commit_note
(
HashWithIndifferentAccess
.
new
(
params
[
:commit
]))
create_commit_note
(
HashWithIndifferentAccess
.
new
(
params
[
:commit
]))
...
@@ -31,40 +56,27 @@ module ChatMessage
...
@@ -31,40 +56,27 @@ module ChatMessage
end
end
end
end
def
attachments
description_message
end
private
def
format_title
(
title
)
def
format_title
(
title
)
title
.
lines
.
first
.
chomp
title
.
lines
.
first
.
chomp
end
end
def
create_issue_note
(
issue
)
{
target:
"issue #
#{
issue
[
:iid
]
}
"
,
title:
format_title
(
issue
[
:title
])
}
end
def
create_commit_note
(
commit
)
def
create_commit_note
(
commit
)
commit_sha
=
commit
[
:id
]
commit_sha
=
commit
[
:id
]
commit_sha
=
Commit
.
truncate_sha
(
commit_sha
)
commit_sha
=
Commit
.
truncate_sha
(
commit_sha
)
commented_on_message
(
"commit
#{
commit_sha
}
"
,
format_title
(
commit
[
:message
]))
end
def
create_issue_note
(
issue
)
{
target:
"commit
#{
commit_sha
}
"
,
title:
format_title
(
commit
[
:message
])
}
commented_on_message
(
"issue #
#{
issue
[
:iid
]
}
"
,
format_title
(
issue
[
:title
]))
end
end
def
create_merge_note
(
merge_request
)
def
create_merge_note
(
merge_request
)
commented_on_message
(
{
target:
"merge request !
#{
merge_request
[
:iid
]
}
"
,
title:
format_title
(
merge_request
[
:title
])
}
"merge request !
#{
merge_request
[
:iid
]
}
"
,
format_title
(
merge_request
[
:title
]))
end
end
def
create_snippet_note
(
snippet
)
def
create_snippet_note
(
snippet
)
commented_on_message
(
{
target:
"snippet #
#{
snippet
[
:id
]
}
"
,
title:
format_title
(
snippet
[
:title
])
}
"snippet #
#{
snippet
[
:id
]
}
"
,
format_title
(
snippet
[
:title
]))
end
end
def
description_message
def
description_message
...
@@ -75,8 +87,8 @@ module ChatMessage
...
@@ -75,8 +87,8 @@ module ChatMessage
link
(
project_name
,
project_url
)
link
(
project_name
,
project_url
)
end
end
def
commented_on_message
(
target
,
title
)
def
commented_on_message
(
target
:,
title
:
)
@message
=
"
#{
user_name
}
#{
link
(
'commented on '
+
target
,
note_url
)
}
in
#{
project_link
}
: *
#{
title
}
*"
"
#{
user_name
}
#{
link
(
'commented on '
+
target
,
note_url
)
}
in
#{
project_link
}
: *
#{
title
}
*"
end
end
end
end
end
end
app/models/project_services/chat_message/push_message.rb
View file @
7dd645e6
...
@@ -9,6 +9,7 @@ module ChatMessage
...
@@ -9,6 +9,7 @@ module ChatMessage
attr_reader
:ref_type
attr_reader
:ref_type
attr_reader
:user_name
attr_reader
:user_name
attr_reader
:user_avatar
attr_reader
:user_avatar
attr_reader
:markdown_format
def
initialize
(
params
)
def
initialize
(
params
)
@after
=
params
[
:after
]
@after
=
params
[
:after
]
...
@@ -20,7 +21,7 @@ module ChatMessage
...
@@ -20,7 +21,7 @@ module ChatMessage
@ref
=
Gitlab
::
Git
.
ref_name
(
params
[
:ref
])
@ref
=
Gitlab
::
Git
.
ref_name
(
params
[
:ref
])
@user_name
=
params
[
:user_name
]
@user_name
=
params
[
:user_name
]
@user_avatar
=
params
[
:user_avatar
]
@user_avatar
=
params
[
:user_avatar
]
@format
=
params
[
:format
]
@
markdown_
format
=
params
[
:format
]
end
end
def
activity
def
activity
...
@@ -28,18 +29,14 @@ module ChatMessage
...
@@ -28,18 +29,14 @@ module ChatMessage
title:
activity_title
,
title:
activity_title
,
subtitle:
"to:
#{
project_link
}
"
,
subtitle:
"to:
#{
project_link
}
"
,
text:
compare_link
,
text:
compare_link
,
image:
params
[
:user_avatar
]
image:
user_avatar
}
}
end
end
def
pretext
@format
?
format
(
message
)
:
message
end
def
attachments
def
attachments
return
[]
if
new_branch?
||
removed_branch?
return
[]
if
new_branch?
||
removed_branch?
@format
?
commit_message_attachments
:
commit_message
s
markdown_format
?
commit_messages
:
commit_message_attachment
s
end
end
private
private
...
...
app/models/project_services/chat_notification_service.rb
View file @
7dd645e6
...
@@ -52,7 +52,7 @@ class ChatNotificationService < Service
...
@@ -52,7 +52,7 @@ class ChatNotificationService < Service
data
=
data
.
merge
(
data
=
data
.
merge
(
project_url:
project_url
,
project_url:
project_url
,
project_name:
project_name
,
project_name:
project_name
,
format:
tru
e
format:
fals
e
)
)
# WebHook events often have an 'update' event that follows a 'open' or
# 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
...
@@ -50,7 +50,7 @@ class MicrosoftTeamsService < ChatNotificationService
data
=
data
.
merge
(
data
=
data
.
merge
(
project_url:
project_url
,
project_url:
project_url
,
project_name:
project_name
,
project_name:
project_name
,
format:
fals
e
format:
tru
e
)
)
message
=
get_message
(
object_kind
,
data
)
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