Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
9bfa0a5f
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
9bfa0a5f
编写于
4月 03, 2017
作者:
T
Tiago Botelho
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
adds remaining messages
上级
7dd645e6
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
72 addition
and
19 deletion
+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
未找到文件。
app/models/project_services/chat_message/base_message.rb
浏览文件 @
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
浏览文件 @
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
浏览文件 @
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
浏览文件 @
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
浏览文件 @
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
浏览文件 @
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
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录