Fix crash when serializing quotes of deleted posts for ActivityPub (#36381)

This commit is contained in:
Claire
2025-10-09 15:52:38 +02:00
committed by GitHub
parent b7c5e60426
commit d4a4a7177a
8 changed files with 97 additions and 8 deletions

View File

@@ -32,8 +32,8 @@ class ActivityPub::NoteSerializer < ActivityPub::Serializer
attribute :voters_count, if: :poll_and_voters_count?
attribute :quote, if: :quote?
attribute :quote, key: :_misskey_quote, if: :quote?
attribute :quote, key: :quote_uri, if: :quote?
attribute :quote, key: :_misskey_quote, if: :serializable_quote?
attribute :quote, key: :quote_uri, if: :serializable_quote?
attribute :quote_authorization, if: :quote_authorization?
attribute :interaction_policy
@@ -214,13 +214,17 @@ class ActivityPub::NoteSerializer < ActivityPub::Serializer
object.quote&.present?
end
def serializable_quote?
object.quote&.quoted_status&.present?
end
def quote_authorization?
object.quote.present? && ActivityPub::TagManager.instance.approval_uri_for(object.quote).present?
end
def quote
# TODO: handle inlining self-quotes
ActivityPub::TagManager.instance.uri_for(object.quote.quoted_status)
object.quote.quoted_status.present? ? ActivityPub::TagManager.instance.uri_for(object.quote.quoted_status) : { type: 'Tombstone' }
end
def quote_authorization