about summary refs log tree commit diff
path: root/app/workers
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2017-04-05 19:46:28 +0200
committerEugen Rochko <eugen@zeonfederated.com>2017-04-05 19:46:28 +0200
commitd13d169922c7efeb6e6c20ef6a271eeda552275f (patch)
tree297367867dfee6a584bcd16d631a2f8714ddfd80 /app/workers
parent29ffe1cad3f473c7b6c0b651d065f8ed9373d37e (diff)
parent5b95be1c42ba69c9a3a79cfa990c80a5f2debfc6 (diff)
Merge branch 'krainboltgreene-broadcast-to-worker'
Diffstat (limited to 'app/workers')
-rw-r--r--app/workers/push_update_worker.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/app/workers/push_update_worker.rb b/app/workers/push_update_worker.rb
new file mode 100644
index 000000000..fbcdcf634
--- /dev/null
+++ b/app/workers/push_update_worker.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+class PushUpdateWorker
+  include Sidekiq::Worker
+
+  def perform(account_id, status_id)
+    account = Account.find(account_id)
+    status  = Status.find(status_id)
+    message = InlineRenderer.render(status, account, 'api/v1/statuses/show')
+
+    Redis.current.publish("timeline:#{account.id}", Oj.dump(event: :update, payload: message, queued_at: (Time.now.to_f * 1000.0).to_i))
+  rescue ActiveRecord::RecordNotFound
+    true
+  end
+end