diff --git a/app/workers/delivery_emoji_reaction_worker.rb b/app/workers/delivery_emoji_reaction_worker.rb index 00462ef01c..637a7f463b 100644 --- a/app/workers/delivery_emoji_reaction_worker.rb +++ b/app/workers/delivery_emoji_reaction_worker.rb @@ -16,11 +16,10 @@ class DeliveryEmojiReactionWorker policy = status.account.emoji_reaction_policy return if policy == :block_and_hide - scope.includes(:user).find_each do |account| + scope.select(:id).merge(policy_scope(status.account, policy)).includes(:user).find_each do |account| next if account.user.present? && (account.user.setting_stop_emoji_reaction_streaming || !account.user.setting_enable_emoji_reaction) next unless redis.exists?("subscribed:timeline:#{account.id}") - next if account.excluded_from_timeline_domains.include?(reacted_account.domain) - next if policy != :allow && !status.account.show_emoji_reaction?(account) + next if !reacted_account.local? && account.excluded_from_timeline_domains.include?(reacted_account.domain) redis.publish("timeline:#{account.id}", payload_json) end @@ -30,4 +29,21 @@ class DeliveryEmojiReactionWorker rescue ActiveRecord::RecordNotFound true end + + def policy_scope(account, policy) + case policy + when :block_and_hide + Account.where(id: 0) + when :mutuals_only + account.mutuals.local.or(Account.where(id: account)) + when :followees_only + account.following.local.or(Account.where(id: account)) + when :followers_only + account.followers.local.or(Account.where(id: account)) + when :outside_only + account.followers.local.or(Account.where(id: account.following.local)).or(Account.where(id: account)) + else + Account.local + end + end end