wip: don't create notifications from a muted user

This commit is contained in:
Andreas Nedbal 2022-12-28 16:33:19 +01:00 committed by Andreas Nedbal
parent 8017d97784
commit 2a7a17a4c3

View file

@ -41,11 +41,25 @@ class Notification < ApplicationRecord
private private
def make_notification(recipient, target, notification_type) def make_notification(recipient, target, notification_type)
return if get_notification_owner(target).present? && recipient.muting?(get_notification_owner(target))
n = notification_type.new(target: target, n = notification_type.new(target: target,
recipient: recipient, recipient: recipient,
new: true) new: true)
n.save! n.save!
n n
end end
def get_notification_owner(target)
if target.is_a? User
target
elsif target&.user.is_a? User
target.user
elsif target&.source.is_a? User
target.source
else
nil
end
end
end end
end end