Implement Instance Moderation Notes (#31529)
This commit is contained in:
		@@ -18,6 +18,7 @@ module Account::Associations
 | 
			
		||||
        has_many :favourites
 | 
			
		||||
        has_many :featured_tags, -> { includes(:tag) }
 | 
			
		||||
        has_many :list_accounts
 | 
			
		||||
        has_many :instance_moderation_notes
 | 
			
		||||
        has_many :media_attachments
 | 
			
		||||
        has_many :mentions
 | 
			
		||||
        has_many :migrations, class_name: 'AccountMigration'
 | 
			
		||||
 
 | 
			
		||||
@@ -21,6 +21,7 @@ class Instance < ApplicationRecord
 | 
			
		||||
    belongs_to :unavailable_domain
 | 
			
		||||
 | 
			
		||||
    has_many :accounts, dependent: nil
 | 
			
		||||
    has_many :moderation_notes, class_name: 'InstanceModerationNote', dependent: :destroy
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  scope :searchable, -> { where.not(domain: DomainBlock.select(:domain)) }
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										27
									
								
								app/models/instance_moderation_note.rb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								app/models/instance_moderation_note.rb
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,27 @@
 | 
			
		||||
# frozen_string_literal: true
 | 
			
		||||
 | 
			
		||||
# == Schema Information
 | 
			
		||||
#
 | 
			
		||||
# Table name: instance_moderation_notes
 | 
			
		||||
#
 | 
			
		||||
#  id         :bigint(8)        not null, primary key
 | 
			
		||||
#  content    :text
 | 
			
		||||
#  domain     :string           not null
 | 
			
		||||
#  created_at :datetime         not null
 | 
			
		||||
#  updated_at :datetime         not null
 | 
			
		||||
#  account_id :bigint(8)        not null
 | 
			
		||||
#
 | 
			
		||||
class InstanceModerationNote < ApplicationRecord
 | 
			
		||||
  include DomainNormalizable
 | 
			
		||||
  include DomainMaterializable
 | 
			
		||||
 | 
			
		||||
  CONTENT_SIZE_LIMIT = 2_000
 | 
			
		||||
 | 
			
		||||
  belongs_to :account
 | 
			
		||||
  belongs_to :instance, inverse_of: :moderation_notes, foreign_key: :domain, primary_key: :domain, optional: true
 | 
			
		||||
 | 
			
		||||
  scope :chronological, -> { reorder(id: :asc) }
 | 
			
		||||
 | 
			
		||||
  validates :content, presence: true, length: { maximum: CONTENT_SIZE_LIMIT }
 | 
			
		||||
  validates :domain, presence: true, domain: true
 | 
			
		||||
end
 | 
			
		||||
		Reference in New Issue
	
	Block a user