Rename with_lock to with_redis_lock to avoid confusion with ActiveRecord's method (#24741)

This commit is contained in:
Matt Jankowski 2023-05-02 12:16:07 -04:00 committed by GitHub
parent a7df578f97
commit f1c1dd0118
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 19 additions and 26 deletions

View file

@ -24,7 +24,7 @@ class ActivityPub::ProcessAccountService < BaseService
# The key does not need to be unguessable, it just needs to be somewhat unique
@options[:request_id] ||= "#{Time.now.utc.to_i}-#{username}@#{domain}"
with_lock("process_account:#{@uri}") do
with_redis_lock("process_account:#{@uri}") do
@account = Account.remote.find_by(uri: @uri) if @options[:only_key]
@account ||= Account.find_remote(@username, @domain)
@old_public_key = @account&.public_key

View file

@ -35,7 +35,7 @@ class ActivityPub::ProcessStatusUpdateService < BaseService
last_edit_date = @status.edited_at.presence || @status.created_at
# Only allow processing one create/update per status at a time
with_lock("create:#{@uri}") do
with_redis_lock("create:#{@uri}") do
Status.transaction do
record_previous_edit!
update_media_attachments!
@ -58,7 +58,7 @@ class ActivityPub::ProcessStatusUpdateService < BaseService
end
def handle_implicit_update!
with_lock("create:#{@uri}") do
with_redis_lock("create:#{@uri}") do
update_poll!(allow_significant_changes: false)
queue_poll_notifications!
end

View file

@ -23,7 +23,7 @@ class FetchLinkCardService < BaseService
@url = @original_url.to_s
with_lock("fetch:#{@original_url}") do
with_redis_lock("fetch:#{@original_url}") do
@card = PreviewCard.find_by(url: @url)
process_url if @card.nil? || @card.updated_at <= 2.weeks.ago || @card.missing_image?
end

View file

@ -18,7 +18,7 @@ class RemoveStatusService < BaseService
@account = status.account
@options = options
with_lock("distribute:#{@status.id}") do
with_redis_lock("distribute:#{@status.id}") do
@status.discard_with_reblogs
StatusPin.find_by(status: @status)&.destroy

View file

@ -106,7 +106,7 @@ class ResolveAccountService < BaseService
def fetch_account!
return unless activitypub_ready?
with_lock("resolve:#{@username}@#{@domain}") do
with_redis_lock("resolve:#{@username}@#{@domain}") do
@account = ActivityPub::FetchRemoteAccountService.new.call(actor_url, suppress_errors: @options[:suppress_errors])
end

View file

@ -15,7 +15,7 @@ class UnfollowService < BaseService
@target_account = target_account
@options = options
with_lock("relationship:#{[source_account.id, target_account.id].sort.join(':')}") do
with_redis_lock("relationship:#{[source_account.id, target_account.id].sort.join(':')}") do
unfollow! || undo_follow_request!
end
end

View file

@ -18,7 +18,7 @@ class VoteService < BaseService
already_voted = true
with_lock("vote:#{@poll.id}:#{@account.id}") do
with_redis_lock("vote:#{@poll.id}:#{@account.id}") do
already_voted = @poll.votes.where(account: @account).exists?
ApplicationRecord.transaction do