mirror of
https://github.com/Retrospring/retrospring.git
synced 2025-02-13 21:33:20 +01:00
wip: don't create notifications from a muted user
This commit is contained in:
parent
8017d97784
commit
2a7a17a4c3
1 changed files with 14 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue