about summary refs log tree commit diff
path: root/app/serializers/rest/status_serializer.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/serializers/rest/status_serializer.rb')
-rw-r--r--app/serializers/rest/status_serializer.rb18
1 files changed, 17 insertions, 1 deletions
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