about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-11-18 23:24:57 +0100
committerEugen Rochko <eugen@zeonfederated.com>2016-11-18 23:24:57 +0100
commit7dea6a23f7989c1c1693d29f0e0813213173e0f2 (patch)
tree96a2c955578fd560e20c2ea65770a16e238112d0
parent2c58e7e06a5c5e5309255c4cc70605caff8fcb87 (diff)
Move Salmon processing to background as well as PuSH
-rw-r--r--app/controllers/api/salmon_controller.rb2
-rw-r--r--app/workers/salmon_worker.rb9
2 files changed, 10 insertions, 1 deletions
diff --git a/app/controllers/api/salmon_controller.rb b/app/controllers/api/salmon_controller.rb
index 01862a900..a7872d542 100644
--- a/app/controllers/api/salmon_controller.rb
+++ b/app/controllers/api/salmon_controller.rb
@@ -10,7 +10,7 @@ class Api::SalmonController < ApiController
     if body.nil?
       head 200
     else
-      ProcessInteractionService.new.call(body, @account)
+      SalmonWorker.perform_async(@account.id, body.force_encoding('UTF-8'))
       head 201
     end
   end
diff --git a/app/workers/salmon_worker.rb b/app/workers/salmon_worker.rb
new file mode 100644
index 000000000..12b46e92f
--- /dev/null
+++ b/app/workers/salmon_worker.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+class SalmonWorker
+  include Sidekiq::Worker
+
+  def perform(account_id, body)
+    ProcessInteractionService.new.call(body, Account.find(account_id))
+  end
+end