diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2020-08-30 12:33:59 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-30 12:33:59 +0200 |
commit | ce8f33dd2f0fddf4bb30cbcdece8ed102838a0fb (patch) | |
tree | 96eba38afd16041004d03d3de4ca621ad867f669 /app/services | |
parent | bf477cee9f31036ebf3d164ddec1cebef5375513 (diff) |
Fix inefficiencies in fan-out-on-write service (#14682)
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/fan_out_on_write_service.rb | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/app/services/fan_out_on_write_service.rb b/app/services/fan_out_on_write_service.rb index 276eac0c1..21931c2f1 100644 --- a/app/services/fan_out_on_write_service.rb +++ b/app/services/fan_out_on_write_service.rb @@ -6,8 +6,6 @@ class FanOutOnWriteService < BaseService def call(status) raise Mastodon::RaceConditionError if status.visibility.nil? - render_anonymous_payload(status) - if status.direct_visibility? deliver_to_own_conversation(status) elsif status.limited_visibility? @@ -20,6 +18,8 @@ class FanOutOnWriteService < BaseService return if status.account.silenced? || !status.public_visibility? || status.reblog? + render_anonymous_payload(status) + deliver_to_hashtags(status) return if status.reply? && status.in_reply_to_account_id != status.account_id @@ -58,8 +58,10 @@ class FanOutOnWriteService < BaseService def deliver_to_mentioned_followers(status) Rails.logger.debug "Delivering status #{status.id} to limited followers" - FeedInsertWorker.push_bulk(status.mentions.includes(:account).map(&:account).select { |mentioned_account| mentioned_account.local? && mentioned_account.following?(status.account) }) do |follower| - [status.id, follower.id, :home] + status.mentions.joins(:account).merge(status.account.followers_for_local_distribution).select(:id).reorder(nil).find_in_batches do |followers| + FeedInsertWorker.push_bulk(followers) do |follower| + [status.id, follower.id, :home] + end end end |