Fix status processing failing halfway when a remote post has a malformed replies attribute (#31246)

This commit is contained in:
Claire 2024-08-02 12:39:12 +02:00
parent ff90ebffaa
commit d673b6e920

View file

@ -332,13 +332,15 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
def fetch_replies(status) def fetch_replies(status)
collection = @object['replies'] collection = @object['replies']
return if collection.nil? return if collection.blank?
replies = ActivityPub::FetchRepliesService.new.call(status, collection, allow_synchronous_requests: false, request_id: @options[:request_id]) replies = ActivityPub::FetchRepliesService.new.call(status, collection, allow_synchronous_requests: false, request_id: @options[:request_id])
return unless replies.nil? return unless replies.nil?
uri = value_or_id(collection) uri = value_or_id(collection)
ActivityPub::FetchRepliesWorker.perform_async(status.id, uri, { 'request_id' => @options[:request_id] }) unless uri.nil? ActivityPub::FetchRepliesWorker.perform_async(status.id, uri, { 'request_id' => @options[:request_id] }) unless uri.nil?
rescue => e
Rails.logger.warn "Error fetching replies: #{e}"
end end
def conversation_from_uri(uri) def conversation_from_uri(uri)