Fix check for disabling member updated notifications

pull/9685/head
Oliver Günther 3 years ago
parent 7908c7eebe
commit 4ef23efb90
No known key found for this signature in database
GPG Key ID: 88872239EB414F99
  1. 12
      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

Loading…
Cancel
Save