diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2018-11-16 19:46:23 +0100 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2018-12-02 17:14:06 +0100 |
commit | c35be6c7e136261c6a16baaaf936162325fa2b46 (patch) | |
tree | ff14012d3128f9d5579b43698dee58a4b4c1f425 | |
parent | e8a4ba49cfda3b7461fe349266a6ea479e667bf5 (diff) |
Prevent multiple handlers for Delete of Actor from running (#9292)
-rw-r--r-- | app/lib/activitypub/activity.rb | 6 | ||||
-rw-r--r-- | app/lib/activitypub/activity/delete.rb | 6 |
2 files changed, 10 insertions, 2 deletions
diff --git a/app/lib/activitypub/activity.rb b/app/lib/activitypub/activity.rb index 3a39b723ed1..1bb8515ddc1 100644 --- a/app/lib/activitypub/activity.rb +++ b/app/lib/activitypub/activity.rb @@ -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 diff --git a/app/lib/activitypub/activity/delete.rb b/app/lib/activitypub/activity/delete.rb index 457047ac060..8270fed1b20 100644 --- a/app/lib/activitypub/activity/delete.rb +++ b/app/lib/activitypub/activity/delete.rb @@ -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 |