From 50eb8f1f613df0a2379565f5f5eabd8acc110f15 Mon Sep 17 00:00:00 2001 From: Thibaut Girka Date: Tue, 10 Apr 2018 22:13:15 +0200 Subject: Add backend support for bookmarks Bookmarks behave like favourites, except they aren't shared with other users and do not have an associated counter. --- app/serializers/rest/status_serializer.rb | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'app/serializers/rest') diff --git a/app/serializers/rest/status_serializer.rb b/app/serializers/rest/status_serializer.rb index fe3dc9bfc..c8fffcf68 100644 --- a/app/serializers/rest/status_serializer.rb +++ b/app/serializers/rest/status_serializer.rb @@ -8,6 +8,7 @@ class REST::StatusSerializer < ActiveModel::Serializer attribute :favourited, if: :current_user? attribute :reblogged, if: :current_user? attribute :muted, if: :current_user? + attribute :bookmarked, if: :current_user? attribute :pinned, if: :pinnable? belongs_to :reblog, serializer: REST::StatusSerializer @@ -71,6 +72,14 @@ class REST::StatusSerializer < ActiveModel::Serializer end end + def bookmarked + if instance_options && instance_options[:bookmarks] + instance_options[:bookmarks].bookmarks_map[object.id] || false + else + current_user.account.bookmarked?(object) + end + end + def pinned if instance_options && instance_options[:relationships] instance_options[:relationships].pins_map[object.id] || false -- cgit