From 4ef23efb9056ddfdadfa5c8042001f03d7caa039 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20G=C3=BCnther?= Date: Tue, 21 Sep 2021 10:50:34 +0200 Subject: [PATCH] Fix check for disabling member updated notifications --- app/workers/mails/member_job.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/workers/mails/member_job.rb b/app/workers/mails/member_job.rb index 4e57bf1891..d6babfc6eb 100644 --- a/app/workers/mails/member_job.rb +++ b/app/workers/mails/member_job.rb @@ -54,18 +54,24 @@ class Mails::MemberJob < ApplicationJob end def send_updated_global(current_user, member, member_message) + return if sending_disabled?(:updated, member.user_id) + MemberMailer .updated_global(current_user, member, member_message) .deliver_now end def send_added_project(current_user, member, member_message) + return if sending_disabled?(:added, member.user_id) + MemberMailer .added_project(current_user, member, member_message) .deliver_now end def send_updated_project(current_user, member, member_message) + return if sending_disabled?(:updated, member.user_id) + MemberMailer .updated_project(current_user, member, member_message) .deliver_now @@ -78,4 +84,10 @@ class Mails::MemberJob < ApplicationJob .includes(:project, :principal, :roles, :member_roles) .each(&block) end + + def sending_disabled?(setting, user_id) + NotificationSetting + .where(project_id: nil, user_id: user_id) + .exists?("membership_#{setting}" => false) + end end