about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-11-15 15:43:33 +0100
committerEugen Rochko <eugen@zeonfederated.com>2016-11-15 15:43:33 +0100
commita91c3ef6cef0fe5a1645c043e7d4a5ef96e82c4f (patch)
tree248345f3b94384a9bb2a1243ebc0845ebe1af01e /app
parentcea28e0c1d91489756491f24a3e1376188d2bbf8 (diff)
Delegate processing of incoming PuSH data to background workers
Diffstat (limited to 'app')
-rw-r--r--app/controllers/api/subscriptions_controller.rb2
-rw-r--r--app/workers/processing_worker.rb7
2 files changed, 8 insertions, 1 deletions
diff --git a/app/controllers/api/subscriptions_controller.rb b/app/controllers/api/subscriptions_controller.rb
index c3aeee94d..058ae8f5e 100644
--- a/app/controllers/api/subscriptions_controller.rb
+++ b/app/controllers/api/subscriptions_controller.rb
@@ -16,7 +16,7 @@ class Api::SubscriptionsController < ApiController
     subscription = @account.subscription(api_subscription_url(@account.id))
 
     if subscription.verify(body, request.headers['HTTP_X_HUB_SIGNATURE'])
-      ProcessFeedService.new.call(body, @account)
+      ProcessingWorker.perform_async(@account.id, body.force_encoding('UTF-8'))
       head 201
     else
       head 202
diff --git a/app/workers/processing_worker.rb b/app/workers/processing_worker.rb
new file mode 100644
index 000000000..87ebbc5ea
--- /dev/null
+++ b/app/workers/processing_worker.rb
@@ -0,0 +1,7 @@
+class ProcessingWorker
+  include Sidekiq::Worker
+
+  def perform(account_id, body)
+    ProcessFeedService.new.call(body, Account.find(account_id))
+  end
+end