Don't receive questions from muted users

This commit is contained in:
Andreas Nedbal 2022-12-28 03:04:46 +01:00 committed by Andreas Nedbal
parent 409c8372ba
commit 8017d97784
2 changed files with 3 additions and 1 deletions

View File

@ -15,6 +15,7 @@ class QuestionWorker
next if f.inbox_locked?
next if f.banned?
next if MuteRule.where(user: f).any? { |rule| rule.applies_to? question }
next if user.muting?(question.user)
Inbox.create(user_id: f.id, question_id: question_id, new: true)
end

View File

@ -80,7 +80,8 @@ module UseCase
def filtered?(question)
target_user.mute_rules.any? { |rule| rule.applies_to? question } ||
(anonymous && AnonymousBlock.where(identifier: question.author_identifier, user_id: [target_user.id, nil]).any?) ||
(source_user_id && anonymous && AnonymousBlock.where(target_user_id: [source_user.id, nil], user_id: [target_user.id, nil]).any?)
(source_user_id && anonymous && AnonymousBlock.where(target_user_id: [source_user.id, nil], user_id: [target_user.id, nil]).any?) ||
(source_user_id && target_user.muting?(source_user))
end
def source_user