Add support for importing embedded self-quotes (#34584)

This commit is contained in:
Claire 2025-05-05 10:01:16 +02:00 committed by GitHub
parent d41a741e00
commit cbaba54e9d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 67 additions and 16 deletions

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,23 @@ 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)
embedded_quote = safe_prefetched_embed(@account, @status_parser.quoted_object, @activity_json['context'])
ActivityPub::VerifyQuoteService.new.call(quote, fetchable_quoted_uri: quote_uri, prefetched_quoted_object: embedded_quote, 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