]> cat aescling's git repositories - mastodon.git/commitdiff
Optimize RemoveStatusService by removing n+1 query and using shared inboxes (#10247)
authorEugen Rochko <eugen@zeonfederated.com>
Tue, 12 Mar 2019 21:34:55 +0000 (22:34 +0100)
committerGitHub <noreply@github.com>
Tue, 12 Mar 2019 21:34:55 +0000 (22:34 +0100)
app/services/remove_status_service.rb

index 2012f15fc7fac204963afc973eca8a20da4f9c5d..98875429d12fbed7c93b66ded91deb85f6987fc2 100644 (file)
@@ -10,7 +10,7 @@ class RemoveStatusService < BaseService
     @account      = status.account
     @tags         = status.tags.pluck(:name).to_a
     @mentions     = status.active_mentions.includes(:account).to_a
-    @reblogs      = status.reblogs.to_a
+    @reblogs      = status.reblogs.includes(:account).to_a
     @stream_entry = status.stream_entry
     @options      = options
 
@@ -77,8 +77,8 @@ class RemoveStatusService < BaseService
     end
 
     # ActivityPub
-    ActivityPub::DeliveryWorker.push_bulk(target_accounts.select(&:activitypub?).uniq(&:inbox_url)) do |target_account|
-      [signed_activity_json, @account.id, target_account.inbox_url]
+    ActivityPub::DeliveryWorker.push_bulk(target_accounts.select(&:activitypub?).uniq(&:preferred_inbox_url)) do |target_account|
+      [signed_activity_json, @account.id, target_account.preferred_inbox_url]
     end
   end