about summary refs log tree commit diff
path: root/app/services/fan_out_on_write_service.rb
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2022-11-06 09:50:41 +0100
committerClaire <claire.github-309c@sitedethib.com>2022-11-06 09:50:41 +0100
commit0ad919b19257b7d8eb447f7955030927d26cdbe6 (patch)
treed78bd5ba447da166bb7d97a3df3e6d97902a5cdb /app/services/fan_out_on_write_service.rb
parent2f8fb49d1314db931385089bc9004a48700161ad (diff)
parent5187e4e758b0636432d984d1a95a310cac536205 (diff)
Merge branch 'main' into glitch-soc/merge-upstream
Conflicts:
- `app/javascript/mastodon/features/compose/components/poll_form.js`:
  glitch-soc change because of having changed the default number of
  available poll options.
  Applied upstream's changes while keeping glitch-soc's default number of
  poll options.
- `public/oops.png`:
  We had a minor graphics change, probably not worth diverging from upstream.
  Took upstream version.
Diffstat (limited to 'app/services/fan_out_on_write_service.rb')
-rw-r--r--app/services/fan_out_on_write_service.rb11
1 files changed, 10 insertions, 1 deletions
diff --git a/app/services/fan_out_on_write_service.rb b/app/services/fan_out_on_write_service.rb
index 1df522459..8e74e152e 100644
--- a/app/services/fan_out_on_write_service.rb
+++ b/app/services/fan_out_on_write_service.rb
@@ -14,6 +14,7 @@ class FanOutOnWriteService < BaseService
     @options   = options
 
     check_race_condition!
+    warm_payload_cache!
 
     fan_out_to_local_recipients!
     fan_out_to_public_recipients! if broadcastable?
@@ -143,13 +144,21 @@ class FanOutOnWriteService < BaseService
     AccountConversation.add_status(@account, @status) unless update?
   end
 
+  def warm_payload_cache!
+    Rails.cache.write("fan-out/#{@status.id}", rendered_status)
+  end
+
   def anonymous_payload
     @anonymous_payload ||= Oj.dump(
       event: update? ? :'status.update' : :update,
-      payload: InlineRenderer.render(@status, nil, :status)
+      payload: rendered_status
     )
   end
 
+  def rendered_status
+    @rendered_status ||= InlineRenderer.render(@status, nil, :status)
+  end
+
   def update?
     @options[:update]
   end