1 # == Schema Information
3 # Table name: user_mutes
5 # id :bigint(8) not null, primary key
6 # owner_id :bigint(8) not null
7 # subject_id :bigint(8) not null
8 # created_at :datetime not null
9 # updated_at :datetime not null
13 # index_user_mutes_on_owner_id_and_subject_id (owner_id,subject_id) UNIQUE
17 # fk_rails_... (owner_id => users.id)
18 # fk_rails_... (subject_id => users.id)
20 class UserMute < ApplicationRecord
21 belongs_to :owner, :class_name => "User"
22 belongs_to :subject, :class_name => "User"
24 validates :subject, :uniqueness => { :scope => :owner_id, :message => :is_already_muted }
26 def self.active?(owner:, subject:)
27 !subject.administrator? &&
28 !subject.moderator? &&