mirror of
https://github.com/mastodon/mastodon.git
synced 2024-11-23 04:55:08 +01:00
Serialize language into ActivityPub JSON (#7840)
* Serialize language into ActivityPub JSON * Only use contentMap if language is present
This commit is contained in:
parent
50689f0d41
commit
908a9671d0
@ -1,12 +1,15 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ActivityPub::NoteSerializer < ActiveModel::Serializer
|
||||
attributes :id, :type, :summary, :content,
|
||||
attributes :id, :type, :summary,
|
||||
:in_reply_to, :published, :url,
|
||||
:attributed_to, :to, :cc, :sensitive,
|
||||
:atom_uri, :in_reply_to_atom_uri,
|
||||
:conversation
|
||||
|
||||
attribute :content, unless: :language?
|
||||
attribute :content_map, if: :language?
|
||||
|
||||
has_many :media_attachments, key: :attachment
|
||||
has_many :virtual_tags, key: :tag
|
||||
|
||||
@ -26,6 +29,14 @@ class ActivityPub::NoteSerializer < ActiveModel::Serializer
|
||||
Formatter.instance.format(object)
|
||||
end
|
||||
|
||||
def content_map
|
||||
{ object.language => Formatter.instance.format(object) }
|
||||
end
|
||||
|
||||
def language?
|
||||
object.language.present?
|
||||
end
|
||||
|
||||
def in_reply_to
|
||||
return unless object.reply? && !object.thread.nil?
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user