Fix handling of inlined featured collections in ActivityPub actor objects (#34789)

This commit is contained in:
Claire 2025-05-23 17:01:07 +02:00 committed by GitHub
parent 3bf128e62a
commit 304c0417ed
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 79 additions and 32 deletions

View file

@ -4,13 +4,11 @@ class ActivityPub::FetchFeaturedCollectionService < BaseService
include JsonLdHelper
def call(account, **options)
return if account.featured_collection_url.blank? || account.suspended? || account.local?
return if (account.featured_collection_url.blank? && options[:collection].blank?) || account.suspended? || account.local?
@account = account
@options = options
@json = fetch_resource(@account.featured_collection_url, true, local_follower)
return unless supported_context?(@json)
@json = fetch_collection(options[:collection].presence || @account.featured_collection_url)
process_items(collection_items(@json))
end

View file

@ -57,7 +57,7 @@ class ActivityPub::ProcessAccountService < BaseService
after_suspension_change! if suspension_changed?
unless @options[:only_key] || @account.suspended?
check_featured_collection! if @account.featured_collection_url.present?
check_featured_collection! if @json['featured'].present?
check_featured_tags_collection! if @json['featuredTags'].present?
check_links! if @account.fields.any?(&:requires_verification?)
end
@ -121,7 +121,7 @@ class ActivityPub::ProcessAccountService < BaseService
end
def set_immediate_attributes!
@account.featured_collection_url = @json['featured'] || ''
@account.featured_collection_url = valid_collection_uri(@json['featured'])
@account.display_name = @json['name'] || ''
@account.note = @json['summary'] || ''
@account.locked = @json['manuallyApprovesFollowers'] || false
@ -186,7 +186,7 @@ class ActivityPub::ProcessAccountService < BaseService
end
def check_featured_collection!
ActivityPub::SynchronizeFeaturedCollectionWorker.perform_async(@account.id, { 'hashtag' => @json['featuredTags'].blank?, 'request_id' => @options[:request_id] })
ActivityPub::SynchronizeFeaturedCollectionWorker.perform_async(@account.id, { 'hashtag' => @json['featuredTags'].blank?, 'collection' => @json['featured'], 'request_id' => @options[:request_id] })
end
def check_featured_tags_collection!

View file

@ -6,7 +6,7 @@ class ActivityPub::SynchronizeFeaturedCollectionWorker
sidekiq_options queue: 'pull', lock: :until_executed, lock_ttl: 1.day.to_i
def perform(account_id, options = {})
options = { note: true, hashtag: false }.deep_merge(options.deep_symbolize_keys)
options = { note: true, hashtag: false }.deep_merge(options.symbolize_keys)
ActivityPub::FetchFeaturedCollectionService.new.call(Account.find(account_id), **options)
rescue ActiveRecord::RecordNotFound