From 6e28a99c8e46295dd049f7af45565d4bea97c725 Mon Sep 17 00:00:00 2001 From: Fire Demon Date: Sun, 16 Aug 2020 03:24:47 -0500 Subject: [Feature] Full article support --- app/serializers/activitypub/note_serializer.rb | 10 +++++++--- app/serializers/rest/status_serializer.rb | 18 +++++++++++++++++- 2 files changed, 24 insertions(+), 4 deletions(-) (limited to 'app/serializers') diff --git a/app/serializers/activitypub/note_serializer.rb b/app/serializers/activitypub/note_serializer.rb index 3d99e29c4..163f25560 100644 --- a/app/serializers/activitypub/note_serializer.rb +++ b/app/serializers/activitypub/note_serializer.rb @@ -51,6 +51,8 @@ class ActivityPub::NoteSerializer < ActivityPub::Serializer end def summary + return Formatter.instance.format(object) if title_present? + object.spoiler_text.presence || (instance_options[:allow_local_only] ? nil : Setting.outgoing_spoilers.presence) end @@ -67,11 +69,11 @@ class ActivityPub::NoteSerializer < ActivityPub::Serializer end def content - Formatter.instance.format(object) + Formatter.instance.format(object, article_content: true) end def content_map - { object.language => Formatter.instance.format(object) } + { object.language => Formatter.instance.format(object, article_content: true) } end def replies @@ -193,7 +195,9 @@ class ActivityPub::NoteSerializer < ActivityPub::Serializer end def title_present? - object.title.present? + return @has_title if defined?(@has_title) + + @has_title = object.title.present? end def server_metadata diff --git a/app/serializers/rest/status_serializer.rb b/app/serializers/rest/status_serializer.rb index 081b42979..dec39ec24 100644 --- a/app/serializers/rest/status_serializer.rb +++ b/app/serializers/rest/status_serializer.rb @@ -7,7 +7,7 @@ class REST::StatusSerializer < ActiveModel::Serializer :favourites_count # Monsterfork additions - attributes :updated_at, :edited, :nest_level, :title + attributes :updated_at, :edited, :nest_level attribute :favourited, if: :current_user? attribute :reblogged, if: :current_user? @@ -24,6 +24,8 @@ class REST::StatusSerializer < ActiveModel::Serializer attribute :hidden, if: :current_user? attribute :conversation_hidden, if: :current_user? attribute :notify, if: :locally_owned? + attribute :title?, key: :article + attribute :article_content, if: :title? belongs_to :reblog, serializer: REST::StatusSerializer belongs_to :application, if: :show_application? @@ -63,6 +65,12 @@ class REST::StatusSerializer < ActiveModel::Serializer object.local? && owned? end + def title? + return @has_title if defined?(@has_title) + + @has_title = object.title.present? + end + def show_application? object.account.user_shows_application? || owned? end @@ -82,10 +90,18 @@ class REST::StatusSerializer < ActiveModel::Serializer ActivityPub::TagManager.instance.uri_for(object) end + def spoiler_text + title? ? object.title : object.spoiler_text + end + def content Formatter.instance.format(object) end + def article_content + Formatter.instance.format(object, article_content: true) + end + def text object.original_text.presence || object.text end -- cgit