Add backend support for bookmarks

Bookmarks behave like favourites, except they aren't shared with other
users and do not have an associated counter.
This commit is contained in:
Thibaut Girka
2018-04-10 22:13:15 +02:00
parent 33c2bbdda7
commit 50eb8f1f61
11 changed files with 188 additions and 1 deletions

View File

@@ -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