Compatible with Misskey quote
This commit is contained in:
parent
2a8f4b5e04
commit
f63fe2bd7d
@ -112,7 +112,7 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
|
|||||||
conversation: conversation_from_uri(@object['conversation']),
|
conversation: conversation_from_uri(@object['conversation']),
|
||||||
media_attachment_ids: process_attachments.take(4).map(&:id),
|
media_attachment_ids: process_attachments.take(4).map(&:id),
|
||||||
poll: process_poll,
|
poll: process_poll,
|
||||||
quote: quote_from_url(@object['quoteUrl']),
|
quote: quote,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -383,7 +383,9 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
|
|||||||
def text_from_content
|
def text_from_content
|
||||||
return Formatter.instance.linkify([[text_from_name, text_from_summary.presence].compact.join("\n\n"), object_url || object_uri].join(' ')) if converted_object_type?
|
return Formatter.instance.linkify([[text_from_name, text_from_summary.presence].compact.join("\n\n"), object_url || object_uri].join(' ')) if converted_object_type?
|
||||||
|
|
||||||
if @object['content'].present?
|
if @object['quoteUrl'].blank? && @object['_misskey_quote'].present?
|
||||||
|
Formatter.instance.linkify(@object['_misskey_content'])
|
||||||
|
elsif @object['content'].present?
|
||||||
@object['content']
|
@object['content']
|
||||||
elsif content_language_map?
|
elsif content_language_map?
|
||||||
@object['contentMap'].values.first
|
@object['contentMap'].values.first
|
||||||
@ -502,10 +504,16 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
|
|||||||
retry
|
retry
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def quote
|
||||||
|
@quote ||= quote_from_url(@object['quoteUrl'] || @object['_misskey_quote'])
|
||||||
|
end
|
||||||
|
|
||||||
def quote_from_url(url)
|
def quote_from_url(url)
|
||||||
return nil if url.nil?
|
return nil if url.nil?
|
||||||
|
|
||||||
quote = ResolveURLService.new.call(url)
|
quote = ResolveURLService.new.call(url)
|
||||||
status_from_uri(quote.uri) if quote
|
status_from_uri(quote.uri) if quote
|
||||||
|
rescue
|
||||||
|
nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -14,6 +14,8 @@ module ActivityPub::CaseTransform
|
|||||||
when String
|
when String
|
||||||
camel_lower_cache[value] ||= if value.start_with?('_:')
|
camel_lower_cache[value] ||= if value.start_with?('_:')
|
||||||
'_:' + value.gsub(/\A_:/, '').underscore.camelize(:lower)
|
'_:' + value.gsub(/\A_:/, '').underscore.camelize(:lower)
|
||||||
|
elsif value.start_with?('_')
|
||||||
|
value
|
||||||
else
|
else
|
||||||
value.underscore.camelize(:lower)
|
value.underscore.camelize(:lower)
|
||||||
end
|
end
|
||||||
|
@ -7,8 +7,11 @@ class ActivityPub::NoteSerializer < ActivityPub::Serializer
|
|||||||
:in_reply_to, :published, :url,
|
:in_reply_to, :published, :url,
|
||||||
:attributed_to, :to, :cc, :sensitive,
|
:attributed_to, :to, :cc, :sensitive,
|
||||||
:atom_uri, :in_reply_to_atom_uri,
|
:atom_uri, :in_reply_to_atom_uri,
|
||||||
:conversation, :quote_url
|
:conversation
|
||||||
|
|
||||||
|
attribute :quote_url, if: -> { object.quote? }
|
||||||
|
attribute :misskey_quote, key: :_misskey_quote, if: -> { object.quote? }
|
||||||
|
attribute :misskey_content, key: :_misskey_content, if: -> { object.quote? }
|
||||||
attribute :content
|
attribute :content
|
||||||
attribute :content_map, if: :language?
|
attribute :content_map, if: :language?
|
||||||
|
|
||||||
@ -126,7 +129,13 @@ class ActivityPub::NoteSerializer < ActivityPub::Serializer
|
|||||||
end
|
end
|
||||||
|
|
||||||
def quote_url
|
def quote_url
|
||||||
object.quote? ? ActivityPub::TagManager.instance.uri_for(object.quote) : nil
|
ActivityPub::TagManager.instance.uri_for(object.quote) if object.quote?
|
||||||
|
end
|
||||||
|
|
||||||
|
alias misskey_quote quote_url
|
||||||
|
|
||||||
|
def misskey_content
|
||||||
|
object.text if object.quote?
|
||||||
end
|
end
|
||||||
|
|
||||||
def local?
|
def local?
|
||||||
|
Loading…
Reference in New Issue
Block a user