parent
c5157ef07b
commit
9caa90025f
59 changed files with 493 additions and 29 deletions
|
@ -77,6 +77,10 @@ class Account < ApplicationRecord
|
|||
has_many :mentions, inverse_of: :account, dependent: :destroy
|
||||
has_many :notifications, inverse_of: :account, dependent: :destroy
|
||||
|
||||
# Pinned statuses
|
||||
has_many :status_pins, inverse_of: :account, dependent: :destroy
|
||||
has_many :pinned_statuses, through: :status_pins, class_name: 'Status', source: :status
|
||||
|
||||
# Media
|
||||
has_many :media_attachments, dependent: :destroy
|
||||
|
||||
|
|
|
@ -138,4 +138,8 @@ module AccountInteractions
|
|||
def reblogged?(status)
|
||||
status.proper.reblogs.where(account: self).exists?
|
||||
end
|
||||
|
||||
def pinned?(status)
|
||||
status_pins.where(status: status).exists?
|
||||
end
|
||||
end
|
||||
|
|
|
@ -164,6 +164,10 @@ class Status < ApplicationRecord
|
|||
ConversationMute.select('conversation_id').where(conversation_id: conversation_ids).where(account_id: account_id).map { |m| [m.conversation_id, true] }.to_h
|
||||
end
|
||||
|
||||
def pins_map(status_ids, account_id)
|
||||
StatusPin.select('status_id').where(status_id: status_ids).where(account_id: account_id).map { |p| [p.status_id, true] }.to_h
|
||||
end
|
||||
|
||||
def reload_stale_associations!(cached_items)
|
||||
account_ids = []
|
||||
|
||||
|
|
16
app/models/status_pin.rb
Normal file
16
app/models/status_pin.rb
Normal file
|
@ -0,0 +1,16 @@
|
|||
# frozen_string_literal: true
|
||||
# == Schema Information
|
||||
#
|
||||
# Table name: status_pins
|
||||
#
|
||||
# id :integer not null, primary key
|
||||
# account_id :integer not null
|
||||
# status_id :integer not null
|
||||
#
|
||||
|
||||
class StatusPin < ApplicationRecord
|
||||
belongs_to :account, required: true
|
||||
belongs_to :status, required: true
|
||||
|
||||
validates_with StatusPinValidator
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue