diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2018-11-16 19:46:23 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-16 19:46:23 +0100 |
commit | 9311430ed7022e2e02fbd0b453adfc43356fdf9d (patch) | |
tree | 41705cfc836b279ff0d3e66e4655f26101326724 /app/lib/activitypub/activity.rb | |
parent | 074960bb0fa59664c0ae1a35ef80301f5033700d (diff) |
Prevent multiple handlers for Delete of Actor from running (#9292)
Diffstat (limited to 'app/lib/activitypub/activity.rb')
-rw-r--r-- | app/lib/activitypub/activity.rb | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/app/lib/activitypub/activity.rb b/app/lib/activitypub/activity.rb index 999954cb5bc..0a729011f22 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 |