about summary refs log tree commit diff
path: root/app/workers
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2022-11-04 13:21:06 +0100
committerGitHub <noreply@github.com>2022-11-04 13:21:06 +0100
commit5f9e47be34fcf42ff7fcd5668c7555d4a38e289a (patch)
tree5f0f22a0297e1235b8189d4cbd1a8568089e6f2d /app/workers
parentb8f6f039563044764336d4c62d87b1d5442d7c8b (diff)
Add caching for payload serialization during fan-out (#19642)
Diffstat (limited to 'app/workers')
-rw-r--r--app/workers/push_update_worker.rb13
1 files changed, 7 insertions, 6 deletions
diff --git a/app/workers/push_update_worker.rb b/app/workers/push_update_worker.rb
index 9f44c32b3..72c781749 100644
--- a/app/workers/push_update_worker.rb
+++ b/app/workers/push_update_worker.rb
@@ -5,11 +5,12 @@ class PushUpdateWorker
   include Redisable
 
   def perform(account_id, status_id, timeline_id = nil, options = {})
-    @account     = Account.find(account_id)
-    @status      = Status.includes(active_mentions: :account, reblog: { active_mentions: :account }).find(status_id)
-    @timeline_id = timeline_id || "timeline:#{account.id}"
+    @status      = Status.find(status_id)
+    @account_id  = account_id
+    @timeline_id = timeline_id || "timeline:#{account_id}"
     @options     = options.symbolize_keys
 
+    render_payload!
     publish!
   rescue ActiveRecord::RecordNotFound
     true
@@ -17,14 +18,14 @@ class PushUpdateWorker
 
   private
 
-  def payload
-    InlineRenderer.render(@status, @account, :status)
+  def render_payload!
+    @payload = StatusCacheHydrator.new(@status).hydrate(@account_id)
   end
 
   def message
     Oj.dump(
       event: update? ? :'status.update' : :update,
-      payload: payload,
+      payload: @payload,
       queued_at: (Time.now.to_f * 1000.0).to_i
     )
   end