Merge branch 'main' into glitch-soc/merge-upstream

This commit is contained in:
Claire
2022-04-28 18:16:42 +02:00
87 changed files with 911 additions and 678 deletions

View File

@ -2,9 +2,10 @@
class DistributionWorker
include Sidekiq::Worker
include Redisable
def perform(status_id, options = {})
RedisLock.acquire(redis: Redis.current, key: "distribute:#{status_id}", autorelease: 5.minutes.seconds) do |lock|
RedisLock.acquire(redis: redis, key: "distribute:#{status_id}", autorelease: 5.minutes.seconds) do |lock|
if lock.acquired?
FanOutOnWriteService.new.call(Status.find(status_id), **options.symbolize_keys)
else

View File

@ -2,12 +2,13 @@
class MergeWorker
include Sidekiq::Worker
include Redisable
def perform(from_account_id, into_account_id)
FeedManager.instance.merge_into_home(Account.find(from_account_id), Account.find(into_account_id))
rescue ActiveRecord::RecordNotFound
true
ensure
Redis.current.del("account:#{into_account_id}:regeneration")
redis.del("account:#{into_account_id}:regeneration")
end
end

View File

@ -2,6 +2,7 @@
class Scheduler::AccountsStatusesCleanupScheduler
include Sidekiq::Worker
include Redisable
# This limit is mostly to be nice to the fediverse at large and not
# generate too much traffic.
@ -83,14 +84,14 @@ class Scheduler::AccountsStatusesCleanupScheduler
end
def last_processed_id
Redis.current.get('account_statuses_cleanup_scheduler:last_account_id')
redis.get('account_statuses_cleanup_scheduler:last_account_id')
end
def save_last_processed_id(id)
if id.nil?
Redis.current.del('account_statuses_cleanup_scheduler:last_account_id')
redis.del('account_statuses_cleanup_scheduler:last_account_id')
else
Redis.current.set('account_statuses_cleanup_scheduler:last_account_id', id, ex: 1.hour.seconds)
redis.set('account_statuses_cleanup_scheduler:last_account_id', id, ex: 1.hour.seconds)
end
end
end