Prevent questions being sent to users that lock their inbox
This commit is contained in:
parent
f6c28eefbd
commit
fa12b19b8a
|
@ -12,6 +12,7 @@ class QuestionWorker
|
|||
question = Question.find(question_id)
|
||||
|
||||
user.followers.each do |f|
|
||||
next if f.inbox_locked?
|
||||
next if MuteRule.where(user: f).any? { |rule| rule.applies_to? question }
|
||||
|
||||
Inbox.create(user_id: f.id, question_id: question_id, new: true)
|
||||
|
|
|
@ -35,6 +35,9 @@ module Errors
|
|||
class SelfAction < Forbidden
|
||||
end
|
||||
|
||||
class InboxLocked < Forbidden
|
||||
end
|
||||
|
||||
class FollowingSelf < SelfAction
|
||||
end
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ module UseCase
|
|||
option :direct, type: Types::Params::Bool, default: proc { true }
|
||||
|
||||
def call
|
||||
check_lock
|
||||
check_anonymous_rules
|
||||
check_blocks
|
||||
|
||||
|
@ -42,6 +43,10 @@ module UseCase
|
|||
|
||||
private
|
||||
|
||||
def check_lock
|
||||
raise Errors::InboxLocked if target_user.inbox_locked?
|
||||
end
|
||||
|
||||
def check_anonymous_rules
|
||||
if !source_user_id && !anonymous
|
||||
# We can not create a non-anonymous question without a source user
|
||||
|
|
Loading…
Reference in New Issue