Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
a71bed53
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 搜索 >>
提交
a71bed53
编写于
8月 07, 2015
作者:
R
Robert Speicher
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'merge-notifs' into 'master'
See merge request !1077
上级
8ab6bd3e
4f24eb2a
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
44 addition
and
52 deletion
+44
-52
CHANGELOG
CHANGELOG
+1
-0
app/services/notification_service.rb
app/services/notification_service.rb
+9
-40
doc/workflow/notifications.md
doc/workflow/notifications.md
+28
-11
spec/services/notification_service_spec.rb
spec/services/notification_service_spec.rb
+6
-1
未找到文件。
CHANGELOG
浏览文件 @
a71bed53
...
...
@@ -32,6 +32,7 @@ v 7.14.0 (unreleased)
- Fix bug causing Bitbucket importer to crash when OAuth application had been removed.
- Add fetch command to the MR page.
- Show who last edited a comment if it wasn't the original author
- Send notification to all participants when MR is merged.
- Add ability to manage user email addresses via the API.
- Show buttons to add license, changelog and contribution guide if they're missing.
- Tweak project page buttons.
...
...
app/services/notification_service.rb
浏览文件 @
a71bed53
...
...
@@ -70,12 +70,6 @@ class NotificationService
reassign_resource_email
(
merge_request
,
merge_request
.
target_project
,
current_user
,
'reassigned_merge_request_email'
)
end
# When we close a merge request we should send next emails:
#
# * merge_request author if their notification level is not Disabled
# * merge_request assignee if their notification level is not Disabled
# * project team members with notification level higher then Participating
#
def
close_mr
(
merge_request
,
current_user
)
close_resource_email
(
merge_request
,
merge_request
.
target_project
,
current_user
,
'closed_merge_request_email'
)
end
...
...
@@ -84,26 +78,8 @@ class NotificationService
reopen_resource_email
(
issue
,
issue
.
project
,
current_user
,
'issue_status_changed_email'
,
'reopened'
)
end
# When we merge a merge request we should send next emails:
#
# * merge_request author if their notification level is not Disabled
# * merge_request assignee if their notification level is not Disabled
# * project team members with notification level higher then Participating
#
def
merge_mr
(
merge_request
,
current_user
)
recipients
=
[
merge_request
.
author
,
merge_request
.
assignee
]
recipients
=
add_project_watchers
(
recipients
,
merge_request
.
target_project
)
recipients
=
reject_muted_users
(
recipients
,
merge_request
.
target_project
)
recipients
=
add_subscribed_users
(
recipients
,
merge_request
)
recipients
=
reject_unsubscribed_users
(
recipients
,
merge_request
)
recipients
.
delete
(
current_user
)
recipients
.
each
do
|
recipient
|
mailer
.
merged_merge_request_email
(
recipient
.
id
,
merge_request
.
id
,
current_user
.
id
)
end
close_resource_email
(
merge_request
,
merge_request
.
target_project
,
current_user
,
'merged_merge_request_email'
)
end
def
reopen_mr
(
merge_request
,
current_user
)
...
...
@@ -364,8 +340,7 @@ class NotificationService
end
def
new_resource_email
(
target
,
project
,
method
)
recipients
=
build_recipients
(
target
,
project
)
recipients
.
delete
(
target
.
author
)
recipients
=
build_recipients
(
target
,
project
,
target
.
author
)
recipients
.
each
do
|
recipient
|
mailer
.
send
(
method
,
recipient
.
id
,
target
.
id
)
...
...
@@ -373,8 +348,7 @@ class NotificationService
end
def
close_resource_email
(
target
,
project
,
current_user
,
method
)
recipients
=
build_recipients
(
target
,
project
)
recipients
.
delete
(
current_user
)
recipients
=
build_recipients
(
target
,
project
,
current_user
)
recipients
.
each
do
|
recipient
|
mailer
.
send
(
method
,
recipient
.
id
,
target
.
id
,
current_user
.
id
)
...
...
@@ -383,8 +357,7 @@ class NotificationService
def
reassign_resource_email
(
target
,
project
,
current_user
,
method
)
assignee_id_was
=
previous_record
(
target
,
"assignee_id"
)
recipients
=
build_recipients
(
target
,
project
)
recipients
.
delete
(
current_user
)
recipients
=
build_recipients
(
target
,
project
,
current_user
)
recipients
.
each
do
|
recipient
|
mailer
.
send
(
method
,
recipient
.
id
,
target
.
id
,
assignee_id_was
,
current_user
.
id
)
...
...
@@ -392,21 +365,15 @@ class NotificationService
end
def
reopen_resource_email
(
target
,
project
,
current_user
,
method
,
status
)
recipients
=
build_recipients
(
target
,
project
)
recipients
.
delete
(
current_user
)
recipients
=
build_recipients
(
target
,
project
,
current_user
)
recipients
.
each
do
|
recipient
|
mailer
.
send
(
method
,
recipient
.
id
,
target
.
id
,
status
,
current_user
.
id
)
end
end
def
build_recipients
(
target
,
project
)
recipients
=
if
target
.
respond_to?
(
:participants
)
target
.
participants
else
[
target
.
author
,
target
.
assignee
]
end
def
build_recipients
(
target
,
project
,
current_user
)
recipients
=
target
.
participants
(
current_user
)
recipients
=
add_project_watchers
(
recipients
,
project
)
recipients
=
reject_mention_users
(
recipients
,
project
)
...
...
@@ -415,6 +382,8 @@ class NotificationService
recipients
=
add_subscribed_users
(
recipients
,
target
)
recipients
=
reject_unsubscribed_users
(
recipients
,
target
)
recipients
.
delete
(
current_user
)
recipients
end
...
...
doc/workflow/notifications.md
浏览文件 @
a71bed53
...
...
@@ -52,18 +52,35 @@ Below is the table of events users can be notified of:
| New SSH key added | User | Security email, always sent. |
| New email added | User | Security email, always sent. |
| New user created | User | Sent on user creation, except for omniauth (LDAP)|
| New issue created | Issue assignee [1], project members [2] | [1] not disabled, [2] higher than participating |
| User added to project | User | Sent when user is added to project |
| Project access level changed | User | Sent when user project access level is changed |
| User added to group | User | Sent when user is added to group |
| Project moved | Project members [1] | [1] not disabled |
| Group access level changed | User | Sent when user group access level is changed |
| Close issue | Issue author [1], issue assignee [2], project members [3] | [1] [2] not disabled, [3] higher than participating |
| Reassign issue | New issue assignee [1], old issue assignee [2] | [1] [2] not disabled |
| Reopen issue | Project members [1] | [1] higher than participating |
| New merge request | MR assignee [1] | [1] not disabled |
| Reassign merge request | New MR assignee [1], old MR assignee [2] | [1] [2] not disabled |
| Close merge request | MR author [1], MR assignee [2], project members [3] | [1] [2] not disabled, [3] higher than participating |
| Reopen merge request | Project members [1] | [1] higher than participating |
| Merge merge request | MR author [1], MR assignee [2], project members [3] | [1] [2] not disabled, [3] higher than participating |
| New comment | Mentioned users [1], users participating [2], project members [3] | [1] [2] not disabled, [3] higher than participating |
| Project moved | Project members [1] | [1] not disabled |
### Issue / Merge Request events
In all of the below cases, the notification will be sent to:
-
Participants:
-
the author and assignee of the issue/merge request
-
authors of comments on the issue/merge request
-
anyone mentioned by
`@username`
in the issue/merge request description
-
anyone mentioned by
`@username`
in any of the comments on the issue/merge request
...with notification level "Participating" or higher
-
Watchers: project members with notification level "Watch"
-
Subscribers: anyone who manually subscribed to the issue/merge request
| Event | Sent to |
|------------------------|---------|
| New issue | |
| Close issue | |
| Reassign issue | The above, plus the old assignee |
| Reopen issue | |
| New merge request | |
| Reassign merge request | The above, plus the old assignee |
| Close merge request | |
| Reopen merge request | |
| Merge merge request | |
| New comment | The above, plus anyone mentioned by
`@username`
in the comment, with notification level "Mention" or higher |
spec/services/notification_service_spec.rb
浏览文件 @
a71bed53
...
...
@@ -300,7 +300,7 @@ describe NotificationService do
describe
'Merge Requests'
do
let
(
:project
)
{
create
(
:project
,
:public
)
}
let
(
:merge_request
)
{
create
:merge_request
,
source_project:
project
,
assignee:
create
(
:user
)
}
let
(
:merge_request
)
{
create
:merge_request
,
source_project:
project
,
assignee:
create
(
:user
)
,
description:
'cc @participant'
}
before
do
build_team
(
merge_request
.
target_project
)
...
...
@@ -311,6 +311,7 @@ describe NotificationService do
it
do
should_email
(
merge_request
.
assignee_id
)
should_email
(
@u_watcher
.
id
)
should_email
(
@u_participant_mentioned
.
id
)
should_not_email
(
@u_participating
.
id
)
should_not_email
(
@u_disabled
.
id
)
notification
.
new_merge_request
(
merge_request
,
@u_disabled
)
...
...
@@ -329,6 +330,7 @@ describe NotificationService do
it
do
should_email
(
merge_request
.
assignee_id
)
should_email
(
@u_watcher
.
id
)
should_email
(
@u_participant_mentioned
.
id
)
should_email
(
@subscriber
.
id
)
should_not_email
(
@unsubscriber
.
id
)
should_not_email
(
@u_participating
.
id
)
...
...
@@ -349,6 +351,7 @@ describe NotificationService do
it
do
should_email
(
merge_request
.
assignee_id
)
should_email
(
@u_watcher
.
id
)
should_email
(
@u_participant_mentioned
.
id
)
should_email
(
@subscriber
.
id
)
should_not_email
(
@unsubscriber
.
id
)
should_not_email
(
@u_participating
.
id
)
...
...
@@ -369,6 +372,7 @@ describe NotificationService do
it
do
should_email
(
merge_request
.
assignee_id
)
should_email
(
@u_watcher
.
id
)
should_email
(
@u_participant_mentioned
.
id
)
should_email
(
@subscriber
.
id
)
should_not_email
(
@unsubscriber
.
id
)
should_not_email
(
@u_participating
.
id
)
...
...
@@ -389,6 +393,7 @@ describe NotificationService do
it
do
should_email
(
merge_request
.
assignee_id
)
should_email
(
@u_watcher
.
id
)
should_email
(
@u_participant_mentioned
.
id
)
should_email
(
@subscriber
.
id
)
should_not_email
(
@unsubscriber
.
id
)
should_not_email
(
@u_participating
.
id
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录