about summary refs log tree commit diff
path: root/app/services
diff options
context:
space:
mode:
authorEugen <eugen@zeonfederated.com>2017-04-05 18:44:33 +0200
committerGitHub <noreply@github.com>2017-04-05 18:44:33 +0200
commit3d8b80e1cc8206d3a2d9904eb216269f0e38e66a (patch)
tree0bef7e42e35c04b2a4243f458909b86edf5aa278 /app/services
parent7bed4e51db18c864c36c6b48eb22c65f11c16b1c (diff)
parentb142a2ebf51fb140062e52cb283736b6d4abe725 (diff)
Merge branch 'master' into broadcast-to-worker
Diffstat (limited to 'app/services')
-rw-r--r--app/services/fan_out_on_write_service.rb17
1 files changed, 9 insertions, 8 deletions
diff --git a/app/services/fan_out_on_write_service.rb b/app/services/fan_out_on_write_service.rb
index 42222c25b..106d257ba 100644
--- a/app/services/fan_out_on_write_service.rb
+++ b/app/services/fan_out_on_write_service.rb
@@ -16,6 +16,7 @@ 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
@@ -48,23 +49,23 @@ class FanOutOnWriteService < BaseService
     end
   end
 
+  def render_anonymous_payload(status)
+    @payload = FeedManager.instance.inline_render(nil, 'api/v1/statuses/show', status)
+  end
+
   def deliver_to_hashtags(status)
     Rails.logger.debug "Delivering status #{status.id} to hashtags"
 
-    payload = FeedManager.instance.inline_render(nil, 'api/v1/statuses/show', status)
-
     status.tags.pluck(:name).each do |hashtag|
-      FeedManager.instance.broadcast("hashtag:#{hashtag}", event: 'update', payload: payload)
-      FeedManager.instance.broadcast("hashtag:#{hashtag}:local", event: 'update', payload: payload) if status.account.local?
+      FeedManager.instance.broadcast("hashtag:#{hashtag}", event: 'update', payload: @payload)
+      FeedManager.instance.broadcast("hashtag:#{hashtag}:local", event: 'update', payload: @payload) if status.account.local?
     end
   end
 
   def deliver_to_public(status)
     Rails.logger.debug "Delivering status #{status.id} to public timeline"
 
-    payload = FeedManager.instance.inline_render(nil, 'api/v1/statuses/show', status)
-
-    FeedManager.instance.broadcast(:public, event: 'update', payload: payload)
-    FeedManager.instance.broadcast('public:local', event: 'update', payload: payload) if status.account.local?
+    FeedManager.instance.broadcast(:public, event: 'update', payload: @payload)
+    FeedManager.instance.broadcast('public:local', event: 'update', payload: @payload) if status.account.local?
   end
 end