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
9bfa0a5f
Commit
9bfa0a5f
authored
Apr 03, 2017
by
Tiago Botelho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adds remaining messages
parent
7dd645e6
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
72 additions
and
19 deletions
+72
-19
app/models/project_services/chat_message/base_message.rb
app/models/project_services/chat_message/base_message.rb
+4
-0
app/models/project_services/chat_message/issue_message.rb
app/models/project_services/chat_message/issue_message.rb
+16
-8
app/models/project_services/chat_message/merge_message.rb
app/models/project_services/chat_message/merge_message.rb
+11
-2
app/models/project_services/chat_message/pipeline_message.rb
app/models/project_services/chat_message/pipeline_message.rb
+23
-7
app/models/project_services/chat_message/wiki_page_message.rb
...models/project_services/chat_message/wiki_page_message.rb
+14
-1
lib/microsoft_teams/notifier.rb
lib/microsoft_teams/notifier.rb
+4
-1
No files found.
app/models/project_services/chat_message/base_message.rb
View file @
9bfa0a5f
...
...
@@ -17,6 +17,10 @@ module ChatMessage
raise
NotImplementedError
end
def
activity
raise
NotImplementedError
end
private
def
message
...
...
app/models/project_services/chat_message/issue_message.rb
View file @
9bfa0a5f
module
ChatMessage
class
IssueMessage
<
BaseMessage
attr_reader
:user_name
attr_reader
:user_avatar
attr_reader
:title
attr_reader
:project_name
attr_reader
:project_url
...
...
@@ -9,9 +10,11 @@ module ChatMessage
attr_reader
:action
attr_reader
:state
attr_reader
:description
attr_reader
:markdown_format
def
initialize
(
params
)
@user_name
=
params
[
:user
][
:username
]
@user_avatar
=
params
[
:user
][
:avatar_url
]
@project_name
=
params
[
:project_name
]
@project_url
=
params
[
:project_url
]
...
...
@@ -23,23 +26,28 @@ module ChatMessage
@action
=
obj_attr
[
:action
]
@state
=
obj_attr
[
:state
]
@description
=
obj_attr
[
:description
]
||
''
@markdown_format
=
params
[
:format
]
end
def
attachments
return
[]
unless
opened_issue?
description_message
markdown_format
?
description
:
description_message
end
def
activity
{
title:
"Issue
#{
state
}
by
#{
user_name
}
"
,
subtitle:
"to:
#{
project_link
}
"
,
text:
issue_link
,
image:
user_avatar
}
end
private
def
message
case
state
when
"opened"
"[
#{
project_link
}
] Issue
#{
state
}
by
#{
user_name
}
"
else
"[
#{
project_link
}
] Issue
#{
issue_link
}
#{
state
}
by
#{
user_name
}
"
end
"[
#{
project_link
}
] Issue
#{
issue_link
}
#{
state
}
by
#{
user_name
}
"
end
def
opened_issue?
...
...
@@ -52,7 +60,7 @@ module ChatMessage
title_link:
issue_url
,
text:
format
(
description
),
color:
"#C95823"
}]
}]
end
def
project_link
...
...
app/models/project_services/chat_message/merge_message.rb
View file @
9bfa0a5f
module
ChatMessage
class
MergeMessage
<
BaseMessage
attr_reader
:user_name
attr_reader
:user_avatar
attr_reader
:project_name
attr_reader
:project_url
attr_reader
:merge_request_id
...
...
@@ -8,9 +9,11 @@ module ChatMessage
attr_reader
:target_branch
attr_reader
:state
attr_reader
:title
attr_reader
:markdown_format
def
initialize
(
params
)
@user_name
=
params
[
:user
][
:username
]
@user_avatar
=
params
[
:user
][
:avatar_url
]
@project_name
=
params
[
:project_name
]
@project_url
=
params
[
:project_url
]
...
...
@@ -21,10 +24,16 @@ module ChatMessage
@target_branch
=
obj_attr
[
:target_branch
]
@state
=
obj_attr
[
:state
]
@title
=
format_title
(
obj_attr
[
:title
])
@markdown_format
=
params
[
:format
]
end
def
pretext
format
(
message
)
def
activity
{
title:
"Merge Request
#{
state
}
by
#{
user_name
}
"
,
subtitle:
"to:
#{
project_link
}
"
,
text:
merge_request_link
,
image:
user_avatar
}
end
def
attachments
...
...
app/models/project_services/chat_message/pipeline_message.rb
View file @
9bfa0a5f
module
ChatMessage
class
PipelineMessage
<
BaseMessage
attr_reader
:ref_type
,
:ref
,
:status
,
:project_name
,
:project_url
,
:user_name
,
:duration
,
:pipeline_id
attr_reader
:ref_type
attr_reader
:ref
attr_reader
:status
attr_reader
:project_name
attr_reader
:project_url
attr_reader
:user_name
attr_reader
:duration
attr_reader
:pipeline_id
attr_reader
:user_avatar
attr_reader
:markdown_format
def
initialize
(
data
)
pipeline_attributes
=
data
[
:object_attributes
]
...
...
@@ -14,6 +22,9 @@ module ChatMessage
@project_name
=
data
[
:project
][
:path_with_namespace
]
@project_url
=
data
[
:project
][
:web_url
]
@user_name
=
(
data
[
:user
]
&&
data
[
:user
][
:name
])
||
'API'
@user_avatar
=
data
[
:user
][
:avatar_url
]
||
''
@markdown_format
=
params
[
:format
]
end
def
pretext
...
...
@@ -24,8 +35,17 @@ module ChatMessage
format
(
message
)
end
def
activity
{
title:
"Pipeline
#{
pipeline_link
}
of
#{
branch_link
}
#{
ref_type
}
by
#{
user_name
}
#{
humanized_status
}
"
,
subtitle:
"to:
#{
project_link
}
"
,
text:
"in
#{
duration
}
#{
'second'
.
pluralize
(
duration
)
}
"
,
image:
user_avatar
}
end
def
attachments
[{
text:
format
(
message
),
color:
attachment_color
}]
markdown_format
?
message
:
[{
text:
format
(
message
),
color:
attachment_color
}]
end
private
...
...
@@ -34,10 +54,6 @@ module ChatMessage
"
#{
project_link
}
: Pipeline
#{
pipeline_link
}
of
#{
branch_link
}
#{
ref_type
}
by
#{
user_name
}
#{
humanized_status
}
in
#{
duration
}
#{
'second'
.
pluralize
(
duration
)
}
"
end
def
format
(
string
)
Slack
::
Notifier
::
LinkFormatter
.
format
(
string
)
end
def
humanized_status
case
status
when
'success'
...
...
app/models/project_services/chat_message/wiki_page_message.rb
View file @
9bfa0a5f
...
...
@@ -7,9 +7,11 @@ module ChatMessage
attr_reader
:wiki_page_url
attr_reader
:action
attr_reader
:description
attr_reader
:markdown_format
def
initialize
(
params
)
@user_name
=
params
[
:user
][
:username
]
@user_avatar
=
params
[
:user
][
:avatar_url
]
@project_name
=
params
[
:project_name
]
@project_url
=
params
[
:project_url
]
...
...
@@ -26,10 +28,21 @@ module ChatMessage
when
"update"
"edited"
end
@markdown_format
=
params
[
:format
]
end
def
activity
{
title:
"
#{
user_name
}
#{
action
}
#{
wiki_page_link
}
"
,
subtitle:
"in:
#{
project_link
}
"
,
text:
title
,
image:
user_avatar
}
end
def
attachments
description_message
markdown_format
?
@description
:
description_message
end
private
...
...
lib/microsoft_teams/notifier.rb
View file @
9bfa0a5f
...
...
@@ -25,7 +25,10 @@ module MicrosoftTeams
'activityText'
=>
options
[
:activity
][
:text
],
'activityImage'
=>
options
[
:activity
][
:image
]
}
result
[
'sections'
]
<<
{
'title'
=>
'Details'
,
'facts'
=>
attachments
(
options
[
:attachments
])
}
if
options
[
:attachments
]
if
options
[
:attachments
].
present?
&&
!
options
[
:attachments
].
empty?
result
[
'sections'
]
<<
{
'title'
=>
'Details'
,
'facts'
=>
attachments
(
options
[
:attachments
])
}
end
result
.
to_json
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