Fix error when encountering invalid pinned posts (#17964)

This commit is contained in:
Claire 2022-04-06 20:58:23 +02:00 committed by GitHub
parent 6221b36b27
commit 454ef42aab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -22,9 +22,19 @@ class ActivityPub::FetchFeaturedCollectionService < BaseService
private private
def process_items(items) def process_items(items)
status_ids = items.map { |item| value_or_id(item) } status_ids = items.filter_map do |item|
.filter_map { |uri| ActivityPub::FetchRemoteStatusService.new.call(uri, on_behalf_of: local_follower) unless ActivityPub::TagManager.instance.local_uri?(uri) } uri = value_or_id(item)
.filter_map { |status| status.id if status.account_id == @account.id } next if ActivityPub::TagManager.instance.local_uri?(uri)
status = ActivityPub::FetchRemoteStatusService.new.call(uri, on_behalf_of: local_follower)
next unless status.account_id == @account.id
status.id
rescue ActiveRecord::RecordInvalid => e
Rails.logger.debug "Invalid pinned status #{uri}: #{e.message}"
nil
end
to_remove = [] to_remove = []
to_add = status_ids to_add = status_ids