about summary refs log tree commit diff
path: root/app/workers
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2017-04-05 21:41:50 +0200
committerEugen Rochko <eugen@zeonfederated.com>2017-04-05 21:43:10 +0200
commit5442083b3c44c731679fc489568bf7f70a807a39 (patch)
tree009c6f57e1707356fc2a78822bae7baf2321b405 /app/workers
parentbafbf63fcca81ae9dce3a40959b8a47e5fcfc6ac (diff)
Split SalmonWorker into smaller parts, move profile updating into another job
Diffstat (limited to 'app/workers')
-rw-r--r--app/workers/admin/suspension_worker.rb2
-rw-r--r--app/workers/application_worker.rb2
-rw-r--r--app/workers/distribution_worker.rb5
-rw-r--r--app/workers/remote_profile_update_worker.rb20
-rw-r--r--app/workers/salmon_worker.rb2
5 files changed, 26 insertions, 5 deletions
diff --git a/app/workers/admin/suspension_worker.rb b/app/workers/admin/suspension_worker.rb
index 38761f3b9..7ef2b35ec 100644
--- a/app/workers/admin/suspension_worker.rb
+++ b/app/workers/admin/suspension_worker.rb
@@ -3,6 +3,8 @@
 class Admin::SuspensionWorker
   include Sidekiq::Worker
 
+  sidekiq_options queue: 'pull'
+
   def perform(account_id)
     SuspendAccountService.new.call(Account.find(account_id))
   end
diff --git a/app/workers/application_worker.rb b/app/workers/application_worker.rb
index f2d7c1062..436f24763 100644
--- a/app/workers/application_worker.rb
+++ b/app/workers/application_worker.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
 class ApplicationWorker
   def info(message)
     Rails.logger.info("#{self.class.name} - #{message}")
diff --git a/app/workers/distribution_worker.rb b/app/workers/distribution_worker.rb
index 9a2867ea6..f7953689b 100644
--- a/app/workers/distribution_worker.rb
+++ b/app/workers/distribution_worker.rb
@@ -4,10 +4,7 @@ class DistributionWorker < ApplicationWorker
   include Sidekiq::Worker
 
   def perform(status_id)
-    status = Status.find(status_id)
-
-    FanOutOnWriteService.new.call(status)
-    WarmCacheService.new.call(status)
+    FanOutOnWriteService.new.call(Status.find(status_id))
   rescue ActiveRecord::RecordNotFound
     info("Couldn't find the status")
   end
diff --git a/app/workers/remote_profile_update_worker.rb b/app/workers/remote_profile_update_worker.rb
new file mode 100644
index 000000000..b91dc3466
--- /dev/null
+++ b/app/workers/remote_profile_update_worker.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+class RemoteProfileUpdateWorker
+  include Sidekiq::Worker
+
+  sidekiq_options queue: 'pull'
+
+  def perform(account_id, body, resubscribe)
+    account = Account.find(account_id)
+
+    xml = Nokogiri::XML(body)
+    xml.encoding = 'utf-8'
+
+    author_container = xml.at_xpath('/xmlns:feed', xmlns: TagManager::XMLNS) || xml.at_xpath('/xmlns:entry', xmlns: TagManager::XMLNS)
+
+    UpdateRemoteProfileService.new.call(author_container, account, resubscribe)
+  rescue ActiveRecord::RecordNotFound
+    true
+  end
+end
diff --git a/app/workers/salmon_worker.rb b/app/workers/salmon_worker.rb
index fc95ce47f..d37d40432 100644
--- a/app/workers/salmon_worker.rb
+++ b/app/workers/salmon_worker.rb
@@ -7,7 +7,7 @@ class SalmonWorker
 
   def perform(account_id, body)
     ProcessInteractionService.new.call(body, Account.find(account_id))
-  rescue ActiveRecord::RecordNotFound
+  rescue Nokogiri::XML::XPath::SyntaxError, ActiveRecord::RecordNotFound
     true
   end
 end