]> cat aescling's git repositories - mastodon.git/commitdiff
Ensure SynchronizeFeaturedCollectionWorker is unique and clean up (#7043)
authorEugen Rochko <eugen@zeonfederated.com>
Thu, 12 Apr 2018 23:27:22 +0000 (01:27 +0200)
committerGitHub <noreply@github.com>
Thu, 12 Apr 2018 23:27:22 +0000 (01:27 +0200)
* Ensure SynchronizeFeaturedCollectionWorker is unique and clean up

Fix #7041

* Fix code style issue

app/services/activitypub/process_account_service.rb
app/workers/activitypub/synchronize_featured_collection_worker.rb

index 21c2fc57aad5d8df5e312a5836ff5feb5366067b..4475a90797152151698e0e15a90303b2d7c9d11e 100644 (file)
@@ -22,13 +22,15 @@ class ActivityPub::ProcessAccountService < BaseService
 
         create_account if @account.nil?
         update_account
-        process_tags(@account)
+        process_tags
       end
     end
 
+    return if @account.nil?
+
     after_protocol_change! if protocol_changed?
     after_key_change! if key_changed?
-    check_featured_collection! if @account&.featured_collection_url&.present?
+    check_featured_collection! if @account.featured_collection_url.present?
 
     @account
   rescue Oj::ParseError
@@ -189,17 +191,18 @@ class ActivityPub::ProcessAccountService < BaseService
     { redis: Redis.current, key: "process_account:#{@uri}" }
   end
 
-  def process_tags(account)
+  def process_tags
     return if @json['tag'].blank?
+
     as_array(@json['tag']).each do |tag|
       case tag['type']
       when 'Emoji'
-        process_emoji tag, account
+        process_emoji tag
       end
     end
   end
 
-  def process_emoji(tag, _account)
+  def process_emoji(tag)
     return if skip_download?
     return if tag['name'].blank? || tag['icon'].blank? || tag['icon']['url'].blank?
 
index dd676a3ee11b8db4e8571e8aaeaa9d30dc2715ac..7b16d3426a29b0c8989be2a0b2f1b11757d5c7fc 100644 (file)
@@ -3,7 +3,7 @@
 class ActivityPub::SynchronizeFeaturedCollectionWorker
   include Sidekiq::Worker
 
-  sidekiq_options queue: 'pull'
+  sidekiq_options queue: 'pull', unique: :until_executed
 
   def perform(account_id)
     ActivityPub::FetchFeaturedCollectionService.new.call(Account.find(account_id))