Add initial support for ingesting and verifying remote quote posts (#34370)
This commit is contained in:
parent
a324edabdf
commit
df2611a10f
33 changed files with 1643 additions and 22 deletions
15
app/workers/activitypub/quote_refresh_worker.rb
Normal file
15
app/workers/activitypub/quote_refresh_worker.rb
Normal file
|
@ -0,0 +1,15 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class ActivityPub::QuoteRefreshWorker
|
||||
include Sidekiq::Worker
|
||||
|
||||
sidekiq_options queue: 'pull', retry: 3, dead: false, lock: :until_executed, lock_ttl: 1.day.to_i
|
||||
|
||||
def perform(quote_id)
|
||||
quote = Quote.find_by(id: quote_id)
|
||||
return if quote.nil? || quote.updated_at > Quote::BACKGROUND_REFRESH_INTERVAL.ago
|
||||
|
||||
quote.touch
|
||||
ActivityPub::VerifyQuoteService.new.call(quote)
|
||||
end
|
||||
end
|
19
app/workers/activitypub/refetch_and_verify_quote_worker.rb
Normal file
19
app/workers/activitypub/refetch_and_verify_quote_worker.rb
Normal file
|
@ -0,0 +1,19 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class ActivityPub::RefetchAndVerifyQuoteWorker
|
||||
include Sidekiq::Worker
|
||||
include ExponentialBackoff
|
||||
include JsonLdHelper
|
||||
|
||||
sidekiq_options queue: 'pull', retry: 3
|
||||
|
||||
def perform(quote_id, quoted_uri, options = {})
|
||||
quote = Quote.find(quote_id)
|
||||
ActivityPub::VerifyQuoteService.new.call(quote, fetchable_quoted_uri: quoted_uri, request_id: options[:request_id])
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
# Do nothing
|
||||
true
|
||||
rescue Mastodon::UnexpectedResponseError => e
|
||||
raise e unless response_error_unsalvageable?(e.response)
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue