diff options
author | David Yip <yipdw@member.fsf.org> | 2018-04-13 16:38:15 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-13 16:38:15 -0500 |
commit | b7804028c2708c82cbb15037abe569519975ba9d (patch) | |
tree | a5cf9f9678172c658a9de4be3e8c31f3dc5bfa8c /app/serializers/rest | |
parent | a817f084eafaf5527445c29ab1d68f42b1a2872f (diff) | |
parent | acb434b0c998353e9e39379ecab27f68df41a100 (diff) |
Merge pull request #419 from ThibG/glitch-soc/features/bookmarks
Bookmarks
Diffstat (limited to 'app/serializers/rest')
-rw-r--r-- | app/serializers/rest/status_serializer.rb | 9 |
1 files changed, 9 insertions, 0 deletions
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 |