]> cat aescling's git repositories - mastodon.git/commitdiff
Move rendering of JSON payloads for public/hashtag timelines to
authorEugen Rochko <eugen@zeonfederated.com>
Wed, 1 Feb 2017 23:39:17 +0000 (00:39 +0100)
committerEugen Rochko <eugen@zeonfederated.com>
Wed, 1 Feb 2017 23:39:17 +0000 (00:39 +0100)
FanOutOnWriteService. The only recipient-specific part on them
is reblogged/favourited. But since only newly created statuses
appear on them, it is safe to assume that both attributes would
be false

app/channels/application_cable/channel.rb
app/services/fan_out_on_write_service.rb

index ae69032ce2fe68b34a30ea2ecb5c97f616fd446a..f57bcc56aa03d1e0e608ee9cc76d63dd5dbb0809 100644 (file)
@@ -5,12 +5,12 @@ module ApplicationCable
     protected
 
     def hydrate_status(encoded_message)
-      message = ActiveSupport::JSON.decode(encoded_message)
+      message = OJ.load(encoded_message)
 
       return [nil, message] if message['event'] == 'delete'
 
-      status             = Status.find_by(id: message['payload'])
-      message['payload'] = FeedManager.instance.inline_render(current_user.account, 'api/v1/statuses/show', status)
+      status_json = OJ.load(message['payload'])
+      status      = Status.find(status_json['id'])
 
       [status, message]
     end
index 79c7bf24889e744ec8e19ec808113cdcf885f0f3..13aad463234da561deb4c9d5de2a3b046faf5e76 100644 (file)
@@ -35,12 +35,12 @@ class FanOutOnWriteService < BaseService
   def deliver_to_hashtags(status)
     Rails.logger.debug "Delivering status #{status.id} to hashtags"
     status.tags.find_each do |tag|
-      FeedManager.instance.broadcast("hashtag:#{tag.name}", event: 'update', payload: status.id)
+      FeedManager.instance.broadcast("hashtag:#{tag.name}", event: 'update', payload: FeedManager.instance.inline_render(nil, 'api/v1/statuses/show', status))
     end
   end
 
   def deliver_to_public(status)
     Rails.logger.debug "Delivering status #{status.id} to public timeline"
-    FeedManager.instance.broadcast(:public, event: 'update', payload: status.id)
+    FeedManager.instance.broadcast(:public, event: 'update', payload: FeedManager.instance.inline_render(nil, 'api/v1/statuses/show', status))
   end
 end