Add bookmarks (#7107)
* Add backend support for bookmarks Bookmarks behave like favourites, except they aren't shared with other users and do not have an associated counter. * Add spec for bookmark endpoints * Add front-end support for bookmarks * Introduce OAuth scopes for bookmarks * Add bookmarks to archive takeout * Fix migration * Coding style fixes * Fix rebase issue * Update bookmarked_statuses to latest UI changes * Update bookmark actions to properly reflect status changes in state * Add bookmarks item to single-column layout * Make active bookmarks red
This commit is contained in:
		@@ -54,6 +54,7 @@ class Status < ApplicationRecord
 | 
			
		||||
  belongs_to :reblog, foreign_key: 'reblog_of_id', class_name: 'Status', inverse_of: :reblogs, 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, inverse_of: :status
 | 
			
		||||
@@ -302,6 +303,10 @@ class Status < ApplicationRecord
 | 
			
		||||
      Favourite.select('status_id').where(status_id: status_ids).where(account_id: account_id).each_with_object({}) { |f, h| h[f.status_id] = true }
 | 
			
		||||
    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)
 | 
			
		||||
      unscoped.select('reblog_of_id').where(reblog_of_id: status_ids).where(account_id: account_id).each_with_object({}) { |s, h| h[s.reblog_of_id] = true }
 | 
			
		||||
    end
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user