From 4c9e47f6e054649eefd453089d1658b9508c16fc Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 21 Jun 2013 23:36:02 +0300 Subject: [PATCH] Fix notifications for group projects --- app/services/notification_service.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/app/services/notification_service.rb b/app/services/notification_service.rb index ac2820f..ef8ecd6 100644 --- a/app/services/notification_service.rb +++ b/app/services/notification_service.rb @@ -147,17 +147,17 @@ class NotificationService # Get project users with WATCH notification level def project_watchers(project) + project_watchers = [] + member_methods = { project => :users_projects } + member_methods.merge!(project.group => :users_groups) if project.group - member_methods = [:users_projects] - member_methods << :users_groups if project.group - - member_methods.each do |member_method| + member_methods.each do |object, member_method| # Get project notification settings since it has higher priority - user_ids = project.send(member_method).where(notification_level: Notification::N_WATCH).pluck(:user_id) - project_watchers = User.where(id: user_ids) + user_ids = object.send(member_method).where(notification_level: Notification::N_WATCH).pluck(:user_id) + project_watchers += User.where(id: user_ids) # next collect users who use global settings with watch state - user_ids = project.send(member_method).where(notification_level: Notification::N_GLOBAL).pluck(:user_id) + user_ids = object.send(member_method).where(notification_level: Notification::N_GLOBAL).pluck(:user_id) project_watchers += User.where(id: user_ids, notification_level: Notification::N_WATCH) end @@ -175,7 +175,7 @@ class NotificationService tm = project.users_projects.find_by_user_id(user.id) if !tm && project.group - tm = project.users_groups.find_by_user_id(user.id) + tm = project.group.users_groups.find_by_user_id(user.id) end # reject users who globally disabled notification and has no membership -- libgit2 0.21.2