Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
ce30a56f
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,发现更多精彩内容 >>
提交
ce30a56f
编写于
3月 29, 2014
作者:
M
Marin Jankovski
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add or remove watchers from list based on their notification settings.
上级
f4f0a7e0
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
31 addition
and
15 deletion
+31
-15
app/services/notification_service.rb
app/services/notification_service.rb
+31
-15
未找到文件。
app/services/notification_service.rb
浏览文件 @
ce30a56f
...
...
@@ -178,22 +178,24 @@ class NotificationService
# Get project users with WATCH notification level
def
project_watchers
(
project
)
# Gather all user
ids that have WATCH notification setting for project
project_
notification_uids
=
project_notification_list
(
project
,
Notification
::
N_WATCH
)
# Gather all user
that have WATCH notification setting for project and group
project_
uids
,
group_uids
=
project_and_group_watchers
(
project
,
Notification
::
N_WATCH
)
# Gather all user ids that have WATCH notification setting for group
group_notification_uids
=
group_notification_list
(
project
,
Notification
::
N_WATCH
)
# Gather all user that have WATCH as their GLOBAL setting
global_setting_project
,
global_setting_group
=
project_and_group_watchers
(
project
,
Notification
::
N_GLOBAL
)
global_uids
=
[
global_setting_project
,
global_setting_group
].
flatten
.
uniq
global_watchers_ids
=
User
.
where
(
id:
global_uids
,
notification_level:
Notification
::
N_WATCH
).
pluck
(
:id
)
#
Gather all user ids that have GLOBAL setting
global_notification_uids
=
global_notification_list
(
project
)
#
Select watchers based on what the project setting is
project_watchers
,
user_ids
=
select_watchers
(
global_watchers_ids
,
global_setting_project
,
project_uids
)
project_and_group_uids
=
[
project_notification_uids
,
group_notification_uids
].
flatten
.
uniq
group_
and_project_watchers
=
User
.
where
(
id:
project_and_
group_uids
)
# Select watchers based on what the group setting is
group_
watchers
,
ids
=
select_watchers
(
user_ids
,
global_setting_group
,
group_uids
)
# Find all users that have WATCH as their GLOBAL setting
global_watchers
=
User
.
where
(
id:
global_notification_uids
,
notification_level:
Notification
::
N_WATCH
)
project_watchers
.
concat
(
group_watchers
.
concat
(
ids
)).
uniq
watchers
=
User
.
where
(
id:
project_watchers
)
[
group_and_project_watchers
,
global_watchers
].
flatten
.
uniq
watchers
.
to_a
end
def
project_notification_list
(
project
,
notification_level
)
...
...
@@ -208,11 +210,25 @@ class NotificationService
end
end
def
global_notification_list
(
project
)
def
select_watchers
(
user_ids
,
global_setting
,
setting
)
watchers
=
[]
user_ids
.
each
do
|
i
|
if
setting
.
include?
(
i
)
watchers
<<
i
elsif
global_setting
.
include?
(
i
)
watchers
<<
i
else
user_ids
.
delete
(
i
)
end
end
[
watchers
,
user_ids
]
end
def
project_and_group_watchers
(
project
,
notification_level
)
[
project_notification_list
(
project
,
Notification
::
N_GLOBAL
),
group_notification_list
(
project
,
Notification
::
N_GLOBAL
)
]
.
flatten
project_notification_list
(
project
,
notification_level
),
group_notification_list
(
project
,
notification_level
)
]
end
# Remove users with disabled notifications from array
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录