summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhttp://jneen.net/ <jneen@jneen.net>2017-07-20 11:58:30 -0700
committerhttp://jneen.net/ <jneen@jneen.net>2017-08-03 09:06:15 -0700
commit9cd46811d3dd2e6a0cb1b68ba390f9ab3fc587b7 (patch)
treec7f5b175ab5ea5f44ff662308cb59ce8753bf61c
parentb188e1b9e66eb02ac9b51364dfa33e206ea636c3 (diff)
downloadgitlab-ce-9cd46811d3dd2e6a0cb1b68ba390f9ab3fc587b7.tar.gz
protect against nil project/group/setting
-rw-r--r--app/services/notification_recipient_service.rb8
1 files 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