diff options
author | Fire Demon <firedemon@creature.cafe> | 2020-08-16 03:24:47 -0500 |
---|---|---|
committer | Fire Demon <firedemon@creature.cafe> | 2020-08-30 05:45:18 -0500 |
commit | 6e28a99c8e46295dd049f7af45565d4bea97c725 (patch) | |
tree | 1091cdf9ef010e4edc61e188835f8a691077a6ff /app/serializers/rest | |
parent | d7a405e5e7df0d792a75f27fa404e76ab46aad66 (diff) |
[Feature] Full article support
Diffstat (limited to 'app/serializers/rest')
-rw-r--r-- | app/serializers/rest/status_serializer.rb | 18 |
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 |