Add hidden parameter to domain blocks

This commit is contained in:
KMY 2023-04-28 08:52:50 +09:00
parent 9e055d1439
commit 565e60d0db
9 changed files with 34 additions and 7 deletions

View file

@ -25,6 +25,8 @@
# reject_hashtag :boolean default(FALSE), not null
# reject_straight_follow :boolean default(FALSE), not null
# reject_new_follow :boolean default(FALSE), not null
# hidden :boolean default(FALSE), not null
# hidden_anonymous :boolean default(FALSE), not null
#
class DomainBlock < ApplicationRecord
@ -40,7 +42,7 @@ class DomainBlock < ApplicationRecord
delegate :count, to: :accounts, prefix: true
scope :matches_domain, ->(value) { where(arel_table[:domain].matches("%#{value}%")) }
scope :with_user_facing_limitations, -> { where(severity: [:silence, :suspend]).or(where(reject_media: true)) }
scope :with_user_facing_limitations, -> { where(severity: [:silence, :suspend]).or(where(reject_media: true)).where(hidden: false) }
scope :with_limitations, -> { where(severity: [:silence, :suspend]).or(where(reject_media: true)).or(where(reject_favourite: true)).or(where(reject_reply: true)).or(where(reject_new_follow: true)).or(where(reject_straight_follow: true)) }
scope :by_severity, -> { order(Arel.sql('(CASE severity WHEN 0 THEN 1 WHEN 1 THEN 2 WHEN 2 THEN 0 END), domain')) }