Limiting emoji reaction streaming for policy
This commit is contained in:
parent
2a54352989
commit
fdaaf323c5
1 changed files with 25 additions and 1 deletions
|
@ -13,7 +13,14 @@ class DeliveryEmojiReactionWorker
|
|||
if status.present?
|
||||
return if status.account.excluded_from_timeline_domains.include?(emoji_reaction.account.domain)
|
||||
|
||||
scope_status(status).includes(:user).find_each do |account|
|
||||
scope = scope_status(status)
|
||||
|
||||
policy = status.account.emoji_reaction_policy
|
||||
return if policy == :block_and_hide
|
||||
|
||||
scope = scope.merge(policy_scope(status.account)) unless policy == :allow
|
||||
|
||||
scope.includes(:user).find_each do |account|
|
||||
next unless (account.user.nil? || (!account.user&.setting_stop_emoji_reaction_streaming && !account.user&.setting_enable_emoji_reaction)) && redis.exists?("subscribed:timeline:#{account.id}")
|
||||
next if account.excluded_from_timeline_domains.include?(emoji_reaction.account.domain)
|
||||
|
||||
|
@ -25,4 +32,21 @@ class DeliveryEmojiReactionWorker
|
|||
rescue ActiveRecord::RecordNotFound
|
||||
true
|
||||
end
|
||||
|
||||
def policy_scope(account)
|
||||
case account.emoji_reaction_policy
|
||||
when :blocked, :block_and_hide
|
||||
nil
|
||||
when :followees_only
|
||||
account.following
|
||||
when :followers_only
|
||||
account.followers
|
||||
when :mutuals_only
|
||||
account.mutuals
|
||||
when :outside_only
|
||||
Account.where(id: account.following.pluck(:id) + account.followers.pluck(:id))
|
||||
else
|
||||
Account
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue