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
1 changed files with 14 additions and 0 deletions

View File

@ -41,11 +41,25 @@ class Notification < ApplicationRecord
private
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,
recipient: recipient,
new: true)
n.save!
n
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