Prevent multiple handlers for Delete of Actor from running (#9292)
This commit is contained in:
parent
6d4438a6ae
commit
ecc58c0f23
2 changed files with 10 additions and 2 deletions
|
@ -129,4 +129,10 @@ class ActivityPub::Activity
|
|||
::FetchRemoteStatusService.new.call(@object['url'])
|
||||
end
|
||||
end
|
||||
|
||||
def lock_or_return(key, expire_after = 7.days.seconds)
|
||||
yield if redis.set(key, true, nx: true, ex: expire_after)
|
||||
ensure
|
||||
redis.del(key)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -12,9 +12,11 @@ class ActivityPub::Activity::Delete < ActivityPub::Activity
|
|||
private
|
||||
|
||||
def delete_person
|
||||
lock_or_return("delete_in_progress:#{@account.id}") do
|
||||
SuspendAccountService.new.call(@account)
|
||||
@account.destroy!
|
||||
end
|
||||
end
|
||||
|
||||
def delete_note
|
||||
return if object_uri.nil?
|
||||
|
|
Loading…
Reference in a new issue