diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2022-05-13 00:02:35 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-13 00:02:35 +0200 |
commit | 6cf57c676550068a59149ca82d63fcb5b5431158 (patch) | |
tree | 4832da7de8828519c72a205d9878ccd5a606377a /app/lib/activitypub/activity.rb | |
parent | 12535568f7435ed627c37312782f8ca07e83eca9 (diff) |
Refactor how Redis locks are created (#18400)
* Refactor how Redis locks are created
* Fix autorelease duration on account deletion lock
Diffstat (limited to 'app/lib/activitypub/activity.rb')
-rw-r--r-- | app/lib/activitypub/activity.rb | 17 |
1 files changed, 1 insertions, 16 deletions
diff --git a/app/lib/activitypub/activity.rb b/app/lib/activitypub/activity.rb index 3c51a7a51df..7ff06ea390c 100644 --- a/app/lib/activitypub/activity.rb +++ b/app/lib/activitypub/activity.rb @@ -3,6 +3,7 @@ class ActivityPub::Activity include JsonLdHelper include Redisable + include Lockable SUPPORTED_TYPES = %w(Note Question).freeze CONVERTED_TYPES = %w(Image Audio Video Article Page Event).freeze @@ -157,22 +158,6 @@ class ActivityPub::Activity end end - def lock_or_return(key, expire_after = 2.hours.seconds) - yield if redis.set(key, true, nx: true, ex: expire_after) - ensure - redis.del(key) - end - - def lock_or_fail(key, expire_after = 15.minutes.seconds) - RedisLock.acquire({ redis: redis, key: key, autorelease: expire_after }) do |lock| - if lock.acquired? - yield - else - raise Mastodon::RaceConditionError - end - end - end - def fetch? !@options[:delivery] end |