Skip to content

Commit

Permalink
Add proper message to PushUpdateWorker, use redis directly
Browse files Browse the repository at this point in the history
  • Loading branch information
Gargron authored Apr 5, 2017
1 parent 3d8b80e commit 1b8c244
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions app/workers/push_update_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ class PushUpdateWorker

def perform(timeline, account_id, status_id)
account = Account.find(account_id)
status = Status.find(status_id)
status = Status.find(status_id)

message = Rabl::Renderer.new(
'api/v1/statuses/show',
status,
Expand All @@ -14,6 +15,8 @@ def perform(timeline, account_id, status_id)
scope: InlineRablScope.new(account)
)

ActionCable.server.broadcast("timeline:#{account_id}", type: 'update', timeline: timeline, message: message.render)
Redis.current.publish("timeline:#{timeline_id}", Oj.dump({ event: :update, payload: message, queued_at: (Time.now.to_f * 1000.0).to_i }))
rescue ActiveRecord::RecordNotFound
true
end
end

0 comments on commit 1b8c244

Please sign in to comment.