about summary refs log tree commit diff
path: root/app/serializers
diff options
context:
space:
mode:
authorDavid Yip <yipdw@member.fsf.org>2018-04-14 03:50:31 -0500
committerDavid Yip <yipdw@member.fsf.org>2018-04-14 03:50:31 -0500
commitd66192f21c22dd79735a6c3ea6e2ed115b42e0d0 (patch)
treefec9f7eab346901c571c57023aa6231b0f855421 /app/serializers
parent78aca92689cd896f4be34daeb1852f75abc57472 (diff)
parent95a892accdb6a081447117f49c66431dc7e032fb (diff)
Merge remote-tracking branch 'glitchsoc/master' into gs-master
  Conflicts:
 	db/schema.rb
Diffstat (limited to 'app/serializers')
-rw-r--r--app/serializers/rest/status_serializer.rb9
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