From 9cd46811d3dd2e6a0cb1b68ba390f9ab3fc587b7 Mon Sep 17 00:00:00 2001 From: "http://jneen.net/" Date: Thu, 20 Jul 2017 11:58:30 -0700 Subject: [PATCH] protect against nil project/group/setting --- app/services/notification_recipient_service.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/services/notification_recipient_service.rb b/app/services/notification_recipient_service.rb index 07f5655b826..e1456158ff7 100644 --- a/app/services/notification_recipient_service.rb +++ b/app/services/notification_recipient_service.rb @@ -5,13 +5,13 @@ class NotificationRecipientService attr_reader :project def self.notification_setting_for_user_project(user, project) - project_setting = user.notification_settings_for(project) + project_setting = project && user.notification_settings_for(project) - return project_setting unless project_setting.global? + return project_setting unless project_setting.nil? || project_setting.global? - group_setting = user.notification_settings_for(project.group) + group_setting = project&.group && user.notification_settings_for(project.group) - return group_setting unless group_setting.global? + return group_setting unless group_setting.nil? || group_setting.global? user.global_notification_setting end