about summary refs log tree commit diff
path: root/app/models/status.rb
diff options
context:
space:
mode:
authorThibaut Girka <thib@sitedethib.com>2018-04-10 22:13:15 +0200
committerThibaut Girka <thib@sitedethib.com>2018-04-11 20:40:29 +0200
commit50eb8f1f613df0a2379565f5f5eabd8acc110f15 (patch)
tree008492064435329839a8f29ddf4849e79c80803d /app/models/status.rb
parent33c2bbdda7f94789dc0455711093ee788c64a531 (diff)
Add backend support for bookmarks
Bookmarks behave like favourites, except they aren't shared with other
users and do not have an associated counter.
Diffstat (limited to 'app/models/status.rb')
-rw-r--r--app/models/status.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/app/models/status.rb b/app/models/status.rb
index 7e5ca09e4..34b41d347 100644
--- a/app/models/status.rb
+++ b/app/models/status.rb
@@ -46,6 +46,7 @@ class Status < ApplicationRecord
   belongs_to :reblog, foreign_key: 'reblog_of_id', class_name: 'Status', inverse_of: :reblogs, counter_cache: :reblogs_count, optional: true
 
   has_many :favourites, inverse_of: :status, dependent: :destroy
+  has_many :bookmarks, inverse_of: :status, dependent: :destroy
   has_many :reblogs, foreign_key: 'reblog_of_id', class_name: 'Status', inverse_of: :reblog, dependent: :destroy
   has_many :replies, foreign_key: 'in_reply_to_id', class_name: 'Status', inverse_of: :thread
   has_many :mentions, dependent: :destroy
@@ -216,6 +217,10 @@ class Status < ApplicationRecord
       Favourite.select('status_id').where(status_id: status_ids).where(account_id: account_id).map { |f| [f.status_id, true] }.to_h
     end
 
+    def bookmarks_map(status_ids, account_id)
+      Bookmark.select('status_id').where(status_id: status_ids).where(account_id: account_id).map { |f| [f.status_id, true] }.to_h
+    end
+
     def reblogs_map(status_ids, account_id)
       select('reblog_of_id').where(reblog_of_id: status_ids).where(account_id: account_id).reorder(nil).map { |s| [s.reblog_of_id, true] }.to_h
     end