Skip to content
This repository has been archived by the owner on May 16, 2019. It is now read-only.

Commit

Permalink
Prevent multiple handlers for Delete of Actor from running (mastodon#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Gargron committed Nov 23, 2018
1 parent 6d4438a commit ecc58c0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 6 additions & 0 deletions app/lib/activitypub/activity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,10 @@ def fetch_remote_original_status
::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
6 changes: 4 additions & 2 deletions app/lib/activitypub/activity/delete.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ def perform
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
Expand Down

0 comments on commit ecc58c0

Please sign in to comment.