mirror of
https://github.com/mastodon/mastodon.git
synced 2025-05-09 05:06:14 +00:00
Refactor status update quote processing
This commit is contained in:
parent
e7dd0b37c7
commit
c2ba6b10d7
|
@ -273,7 +273,6 @@ class ActivityPub::ProcessStatusUpdateService < BaseService
|
||||||
def update_quote!
|
def update_quote!
|
||||||
return unless Mastodon::Feature.inbound_quotes_enabled?
|
return unless Mastodon::Feature.inbound_quotes_enabled?
|
||||||
|
|
||||||
quote = nil
|
|
||||||
quote_uri = @status_parser.quote_uri
|
quote_uri = @status_parser.quote_uri
|
||||||
|
|
||||||
if quote_uri.present?
|
if quote_uri.present?
|
||||||
|
@ -294,21 +293,22 @@ class ActivityPub::ProcessStatusUpdateService < BaseService
|
||||||
quote = Quote.create(status: @status, approval_uri: approval_uri)
|
quote = Quote.create(status: @status, approval_uri: approval_uri)
|
||||||
@quote_changed = true
|
@quote_changed = true
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
if quote.present?
|
quote.save
|
||||||
begin
|
|
||||||
quote.save
|
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
|
|
||||||
elsif @status.quote.present?
|
elsif @status.quote.present?
|
||||||
@status.quote.destroy!
|
@status.quote.destroy!
|
||||||
@quote_changed = true
|
@quote_changed = true
|
||||||
end
|
end
|
||||||
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!
|
def update_counts!
|
||||||
likes = @status_parser.favourites_count
|
likes = @status_parser.favourites_count
|
||||||
shares = @status_parser.reblogs_count
|
shares = @status_parser.reblogs_count
|
||||||
|
|
Loading…
Reference in New Issue
Block a user