Fix being able to import more than allowed number of follows (#15384)
* Fix being able to import more than allowed number of follows Without this commit, if someone tries importing a second list of accounts to follow before the first one has been processed, this will queue imports for the two whole lists, even if they exceed the account's allowed number of outgoing follows. This commit changes it so the individual queued imports aren't exempt from the follow limit check (they remain exempt from the rate-limiting check though). * Catch validation errors to not re-queue failed follows Co-authored-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
parent
4580129c98
commit
f1f96ebf02
11 changed files with 38 additions and 16 deletions
|
@ -7,7 +7,7 @@ class AuthorizeFollowWorker
|
|||
source_account = Account.find(source_account_id)
|
||||
target_account = Account.find(target_account_id)
|
||||
|
||||
AuthorizeFollowService.new.call(source_account, target_account)
|
||||
AuthorizeFollowService.new.call(source_account, target_account, bypass_limit: true)
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
true
|
||||
end
|
||||
|
|
|
@ -15,7 +15,11 @@ class Import::RelationshipWorker
|
|||
|
||||
case relationship
|
||||
when 'follow'
|
||||
FollowService.new.call(from_account, target_account, options)
|
||||
begin
|
||||
FollowService.new.call(from_account, target_account, options)
|
||||
rescue ActiveRecord::RecordInvalid
|
||||
raise if FollowLimitValidator.limit_for_account(from_account) < from_account.following_count
|
||||
end
|
||||
when 'unfollow'
|
||||
UnfollowService.new.call(from_account, target_account)
|
||||
when 'block'
|
||||
|
|
|
@ -19,7 +19,7 @@ class RefollowWorker
|
|||
|
||||
# Schedule re-follow
|
||||
begin
|
||||
FollowService.new.call(follower, target_account, reblogs: reblogs, notify: notify)
|
||||
FollowService.new.call(follower, target_account, reblogs: reblogs, notify: notify, bypass_limit: true)
|
||||
rescue Mastodon::NotPermittedError, ActiveRecord::RecordNotFound, Mastodon::UnexpectedResponseError, HTTP::Error, OpenSSL::SSL::SSLError
|
||||
next
|
||||
end
|
||||
|
|
|
@ -14,7 +14,7 @@ class UnfollowFollowWorker
|
|||
reblogs = follow&.show_reblogs?
|
||||
notify = follow&.notify?
|
||||
|
||||
FollowService.new.call(follower_account, new_target_account, reblogs: reblogs, notify: notify, bypass_locked: bypass_locked)
|
||||
FollowService.new.call(follower_account, new_target_account, reblogs: reblogs, notify: notify, bypass_locked: bypass_locked, bypass_limit: true)
|
||||
UnfollowService.new.call(follower_account, old_target_account, skip_unmerge: true)
|
||||
rescue ActiveRecord::RecordNotFound, Mastodon::NotPermittedError
|
||||
true
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue