Merge commit 'aa98c8fbeb
' into kb_migration
This commit is contained in:
commit
370f25f3cd
46 changed files with 714 additions and 288 deletions
|
@ -10,6 +10,16 @@ class ActivityPub::DeliveryWorker
|
|||
|
||||
sidekiq_options queue: 'push', retry: 16, dead: false
|
||||
|
||||
# Unfortunately, we cannot control Sidekiq's jitter, so add our own
|
||||
sidekiq_retry_in do |count|
|
||||
# This is Sidekiq's default delay
|
||||
delay = (count**4) + 15
|
||||
# Our custom jitter, that will be added to Sidekiq's built-in one.
|
||||
# Sidekiq's built-in jitter is `rand(10) * (count + 1)`
|
||||
jitter = rand(0.5 * (count**4))
|
||||
delay + jitter
|
||||
end
|
||||
|
||||
HEADERS = { 'Content-Type' => 'application/activity+json' }.freeze
|
||||
|
||||
def perform(json, source_account_id, inbox_url, options = {})
|
||||
|
|
17
app/workers/activitypub/migrated_follow_delivery_worker.rb
Normal file
17
app/workers/activitypub/migrated_follow_delivery_worker.rb
Normal file
|
@ -0,0 +1,17 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class ActivityPub::MigratedFollowDeliveryWorker < ActivityPub::DeliveryWorker
|
||||
def perform(json, source_account_id, inbox_url, old_target_account_id, options = {})
|
||||
super(json, source_account_id, inbox_url, options)
|
||||
unfollow_old_account!(old_target_account_id)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def unfollow_old_account!(old_target_account_id)
|
||||
old_target_account = Account.find(old_target_account_id)
|
||||
UnfollowService.new.call(@source_account, old_target_account, skip_unmerge: true)
|
||||
rescue
|
||||
true
|
||||
end
|
||||
end
|
|
@ -10,13 +10,7 @@ class UnfollowFollowWorker
|
|||
old_target_account = Account.find(old_target_account_id)
|
||||
new_target_account = Account.find(new_target_account_id)
|
||||
|
||||
follow = follower_account.active_relationships.find_by(target_account: old_target_account)
|
||||
reblogs = follow&.show_reblogs?
|
||||
notify = follow&.notify?
|
||||
languages = follow&.languages
|
||||
|
||||
FollowService.new.call(follower_account, new_target_account, reblogs: reblogs, notify: notify, languages: languages, bypass_locked: bypass_locked, bypass_limit: true)
|
||||
UnfollowService.new.call(follower_account, old_target_account, skip_unmerge: true)
|
||||
FollowMigrationService.new.call(follower_account, new_target_account, old_target_account, bypass_locked: bypass_locked)
|
||||
rescue ActiveRecord::RecordNotFound, Mastodon::NotPermittedError
|
||||
true
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue