1
0
Fork 0
forked from gitea/nas

Fix quote is not set in noteserializer

This commit is contained in:
KMY 2023-09-19 18:22:18 +09:00
parent 77eb7c03d9
commit 818bcc0277
4 changed files with 33 additions and 3 deletions

View file

@ -29,6 +29,7 @@ module ContextHelper
limited_scope: { 'kmyblue' => 'http://kmy.blue/ns#', 'limitedScope' => { '@id' => 'kmyblue:limitedScope', '@type' => '@id' } },
other_setting: { 'fedibird' => 'http://fedibird.com/ns#', 'otherSetting' => 'fedibird:otherSetting' },
references: { 'fedibird' => 'http://fedibird.com/ns#', 'references' => { '@id' => 'fedibird:references', '@type' => '@id' } },
quote_uri: { 'fedibird' => 'http://fedibird.com/ns#', 'quoteUri' => 'fedibird:quoteUri' },
olm: {
'toot' => 'http://joinmastodon.org/ns#', 'Device' => 'toot:Device', 'Ed25519Signature' => 'toot:Ed25519Signature', 'Ed25519Key' => 'toot:Ed25519Key', 'Curve25519Key' => 'toot:Curve25519Key', 'EncryptedMessage' => 'toot:EncryptedMessage', 'publicKeyBase64' => 'toot:publicKeyBase64', 'deviceId' => 'toot:deviceId',
'claim' => { '@type' => '@id', '@id' => 'toot:claim' },

View file

@ -2,6 +2,11 @@
module ActivityPub::CaseTransform
class << self
NO_CONVERT_VALUES = %w(
_misskey_content
_misskey_quote
).freeze
def camel_lower_cache
@camel_lower_cache ||= {}
end
@ -12,7 +17,9 @@ module ActivityPub::CaseTransform
when Hash then value.deep_transform_keys! { |key| camel_lower(key) }
when Symbol then camel_lower(value.to_s).to_sym
when String
camel_lower_cache[value] ||= if value.start_with?('_:')
camel_lower_cache[value] ||= if NO_CONVERT_VALUES.include?(value)
value
elsif value.start_with?('_:')
"_:#{value.delete_prefix('_:').underscore.camelize(:lower)}"
else
value.underscore.camelize(:lower)

View file

@ -3,7 +3,7 @@
class ActivityPub::NoteSerializer < ActivityPub::Serializer
include FormattingHelper
context_extensions :atom_uri, :conversation, :sensitive, :voters_count, :searchable_by, :references, :limited_scope
context_extensions :atom_uri, :conversation, :sensitive, :voters_count, :searchable_by, :references, :limited_scope, :quote_uri
attributes :id, :type, :summary,
:in_reply_to, :published, :url,
@ -165,7 +165,7 @@ class ActivityPub::NoteSerializer < ActivityPub::Serializer
end
def quote?
object.references.count == 1 && object.account.user&.single_ref_to_quote
object.references.count == 1 && object.account.user&.settings&.[]('single_ref_to_quote')
end
def quote_uri