Fix notifications delivered to wrong pubsub channel, optimized RemoveStatusService,

slightly optimized FanOutOnWriteService again
This commit is contained in:
Eugen Rochko
2017-04-06 02:26:59 +02:00
parent dea6e47de0
commit dbd529109e
3 changed files with 21 additions and 18 deletions

View File

@ -51,21 +51,22 @@ class FanOutOnWriteService < BaseService
def render_anonymous_payload(status)
@payload = InlineRenderer.render(status, nil, 'api/v1/statuses/show')
@payload = Oj.dump(event: :update, payload: @payload)
end
def deliver_to_hashtags(status)
Rails.logger.debug "Delivering status #{status.id} to hashtags"
status.tags.pluck(:name).each do |hashtag|
Redis.current.publish("hashtag:#{hashtag}", Oj.dump(event: :update, payload: @payload))
Redis.current.publish("hashtag:#{hashtag}:local", Oj.dump(event: :update, payload: @payload)) if status.account.local?
Redis.current.publish("hashtag:#{hashtag}", @payload)
Redis.current.publish("hashtag:#{hashtag}:local", @payload) if status.local?
end
end
def deliver_to_public(status)
Rails.logger.debug "Delivering status #{status.id} to public timeline"
Redis.current.publish('public', Oj.dump(event: 'update', payload: @payload))
Redis.current.publish('public:local', Oj.dump(event: 'update', payload: @payload)) if status.account.local?
Redis.current.publish('public', @payload)
Redis.current.publish('public:local', @payload) if status.local?
end
end