Appease the dog overlords
Co-authored-by: nilsding <nilsding@nilsding.org>
This commit is contained in:
parent
5a3f2966dd
commit
c20974d182
|
@ -13,10 +13,7 @@ class QuestionWorker
|
||||||
webpush_app = Rpush::App.find_by(name: "webpush")
|
webpush_app = Rpush::App.find_by(name: "webpush")
|
||||||
|
|
||||||
user.followers.each do |f|
|
user.followers.each do |f|
|
||||||
next if f.inbox_locked?
|
next if skip_inbox?(f, question, user)
|
||||||
next if f.banned?
|
|
||||||
next if muted?(f, question)
|
|
||||||
next if user.muting?(question.user)
|
|
||||||
|
|
||||||
inbox = Inbox.create(user_id: f.id, question_id:, new: true)
|
inbox = Inbox.create(user_id: f.id, question_id:, new: true)
|
||||||
f.push_notification(webpush_app, inbox) if webpush_app
|
f.push_notification(webpush_app, inbox) if webpush_app
|
||||||
|
@ -28,6 +25,15 @@ class QuestionWorker
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def skip_inbox?(follower, question, user)
|
||||||
|
return true if follower.inbox_locked?
|
||||||
|
return true if follower.banned?
|
||||||
|
return true if muted?(follower, question)
|
||||||
|
return true if user.muting?(question.user)
|
||||||
|
|
||||||
|
false
|
||||||
|
end
|
||||||
|
|
||||||
def muted?(user, question)
|
def muted?(user, question)
|
||||||
MuteRule.where(user:).any? { |rule| rule.applies_to? question }
|
MuteRule.where(user:).any? { |rule| rule.applies_to? question }
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue