diff options
Diffstat (limited to 'app/models/domain_block.rb')
-rw-r--r-- | app/models/domain_block.rb | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/app/models/domain_block.rb b/app/models/domain_block.rb index 84c08c158..c62ca3d8c 100644 --- a/app/models/domain_block.rb +++ b/app/models/domain_block.rb @@ -3,19 +3,20 @@ # # Table name: domain_blocks # -# id :bigint(8) not null, primary key -# domain :string default(""), not null -# created_at :datetime not null -# updated_at :datetime not null -# severity :integer default("silence") -# reject_media :boolean default(FALSE), not null -# reject_reports :boolean default(FALSE), not null +# id :bigint(8) not null, primary key +# domain :string default(""), not null +# created_at :datetime not null +# updated_at :datetime not null +# severity :integer default("noop") +# reject_media :boolean default(FALSE), not null +# reject_reports :boolean default(FALSE), not null +# force_sensitive :boolean default(FALSE), not null # class DomainBlock < ApplicationRecord include DomainNormalizable - enum severity: [:silence, :suspend, :noop] + enum severity: [:noop, :force_unlisted, :silence, :suspend] validates :domain, presence: true, uniqueness: true @@ -28,10 +29,15 @@ class DomainBlock < ApplicationRecord where(domain: domain, severity: :suspend).exists? end + def self.force_unlisted?(domain) + where(domain: domain, severity: :force_unlisted).exists? + end + def stricter_than?(other_block) return true if suspend? - return false if other_block.suspend? && (silence? || noop?) - return false if other_block.silence? && noop? + return false if other_block.suspend? && !suspend? + return false if other_block.silence? && (noop? || force_unlisted?) + return false if other_block.force_unlisted? && noop? (reject_media || !other_block.reject_media) && (reject_reports || !other_block.reject_reports) end |