]> cat aescling's git repositories - mastodon.git/commitdiff
Move Salmon processing to background as well as PuSH
authorEugen Rochko <eugen@zeonfederated.com>
Fri, 18 Nov 2016 22:24:57 +0000 (23:24 +0100)
committerEugen Rochko <eugen@zeonfederated.com>
Fri, 18 Nov 2016 22:24:57 +0000 (23:24 +0100)
app/controllers/api/salmon_controller.rb
app/workers/salmon_worker.rb [new file with mode: 0644]

index 01862a9000134b214d9bd8f1cf75fecbfe95a987..a7872d5422af1335e39032a73cc8ba94664f0cda 100644 (file)
@@ -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 (file)
index 0000000..12b46e9
--- /dev/null
@@ -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