From 9311430ed7022e2e02fbd0b453adfc43356fdf9d Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Fri, 16 Nov 2018 19:46:23 +0100 Subject: Prevent multiple handlers for Delete of Actor from running (#9292) --- app/lib/activitypub/activity.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'app/lib/activitypub/activity.rb') diff --git a/app/lib/activitypub/activity.rb b/app/lib/activitypub/activity.rb index 999954cb5..0a729011f 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 -- cgit