Browse Source

Prevent multiple handlers for Delete of Actor from running (#9292)

pull/4/head
Eugen Rochko 5 years ago
committed by GitHub
parent
commit
9311430ed7
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 2 deletions
  1. +6
    -0
      app/lib/activitypub/activity.rb
  2. +4
    -2
      app/lib/activitypub/activity/delete.rb

+ 6
- 0
app/lib/activitypub/activity.rb View File

@ -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

+ 4
- 2
app/lib/activitypub/activity/delete.rb View File

@ -12,8 +12,10 @@ class ActivityPub::Activity::Delete < ActivityPub::Activity
private
def delete_person
SuspendAccountService.new.call(@account)
@account.destroy!
lock_or_return("delete_in_progress:#{@account.id}") do
SuspendAccountService.new.call(@account)
@account.destroy!
end
end
def delete_note

Loading…
Cancel
Save