From 3cf262c79bc6a548b4cc686b32c08a941b25eb6a Mon Sep 17 00:00:00 2001 From: 2458773093 <2458773093@protonmail.com> Date: Thu, 1 Aug 2019 13:46:59 +0300 Subject: [PATCH] relationship presenter + serializer updated for quotes --- app/presenters/status_relationships_presenter.rb | 2 +- app/serializers/rest/status_serializer.rb | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/presenters/status_relationships_presenter.rb b/app/presenters/status_relationships_presenter.rb index b04e10e2..f196f0dc 100644 --- a/app/presenters/status_relationships_presenter.rb +++ b/app/presenters/status_relationships_presenter.rb @@ -11,7 +11,7 @@ class StatusRelationshipsPresenter @pins_map = {} else statuses = statuses.compact - status_ids = statuses.flat_map { |s| [s.id, s.reblog_of_id] }.uniq.compact + status_ids = statuses.flat_map { |s| [s.id, s.reblog_of_id, s.quote_of_id] }.uniq.compact conversation_ids = statuses.map(&:conversation_id).compact.uniq pinnable_status_ids = statuses.map(&:proper).select { |s| s.account_id == current_account_id && %w(public unlisted).include?(s.visibility) }.map(&:id) diff --git a/app/serializers/rest/status_serializer.rb b/app/serializers/rest/status_serializer.rb index f94dbca9..c663c909 100644 --- a/app/serializers/rest/status_serializer.rb +++ b/app/serializers/rest/status_serializer.rb @@ -4,7 +4,7 @@ class REST::StatusSerializer < ActiveModel::Serializer attributes :id, :created_at, :in_reply_to_id, :in_reply_to_account_id, :sensitive, :spoiler_text, :visibility, :language, :uri, :url, :replies_count, :reblogs_count, - :favourites_count + :favourites_count, :quote_of_id attribute :favourited, if: :current_user? attribute :reblogged, if: :current_user? @@ -15,6 +15,7 @@ class REST::StatusSerializer < ActiveModel::Serializer attribute :text, if: :source_requested? belongs_to :reblog, serializer: REST::StatusSerializer + belongs_to :quote, serializer: REST::StatusSerializer belongs_to :application, if: :show_application? belongs_to :account, serializer: REST::AccountSerializer belongs_to :group, serializer: REST::GroupSerializer @@ -39,6 +40,10 @@ class REST::StatusSerializer < ActiveModel::Serializer object.in_reply_to_account_id&.to_s end + def quote_of_id + object.quote_of_id&.to_s + end + def current_user? !current_user.nil? end