Refactor status update quote processing

This commit is contained in:
Claire 2025-04-30 15:25:46 +02:00
parent e7dd0b37c7
commit c2ba6b10d7

View File

@ -273,7 +273,6 @@ class ActivityPub::ProcessStatusUpdateService < BaseService
def update_quote!
return unless Mastodon::Feature.inbound_quotes_enabled?
quote = nil
quote_uri = @status_parser.quote_uri
if quote_uri.present?
@ -294,21 +293,22 @@ class ActivityPub::ProcessStatusUpdateService < BaseService
quote = Quote.create(status: @status, approval_uri: approval_uri)
@quote_changed = true
end
end
if quote.present?
begin
quote.save
ActivityPub::VerifyQuoteService.new.call(quote, fetchable_quoted_uri: quote_uri, request_id: @request_id)
rescue Mastodon::UnexpectedResponseError, *Mastodon::HTTP_CONNECTION_ERRORS
ActivityPub::RefetchAndVerifyQuoteWorker.perform_in(rand(30..600).seconds, quote.id, quote_uri, { 'request_id' => @request_id })
end
quote.save
fetch_and_verify_quote!(quote, quote_uri)
elsif @status.quote.present?
@status.quote.destroy!
@quote_changed = true
end
end
def fetch_and_verify_quote!(quote, quote_uri)
ActivityPub::VerifyQuoteService.new.call(quote, fetchable_quoted_uri: quote_uri, request_id: @request_id)
rescue Mastodon::UnexpectedResponseError, *Mastodon::HTTP_CONNECTION_ERRORS
ActivityPub::RefetchAndVerifyQuoteWorker.perform_in(rand(30..600).seconds, quote.id, quote_uri, { 'request_id' => @request_id })
end
def update_counts!
likes = @status_parser.favourites_count
shares = @status_parser.reblogs_count