Addo domein block extra supports
This commit is contained in:
parent
bb7fa1d060
commit
9ad92e6a09
24 changed files with 331 additions and 35 deletions
|
@ -4,16 +4,29 @@
|
|||
#
|
||||
# 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
|
||||
# private_comment :text
|
||||
# public_comment :text
|
||||
# obfuscate :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("silence")
|
||||
# reject_media :boolean default(FALSE), not null
|
||||
# reject_reports :boolean default(FALSE), not null
|
||||
# private_comment :text
|
||||
# public_comment :text
|
||||
# obfuscate :boolean default(FALSE), not null
|
||||
# reject_favourite :boolean default(FALSE), not null
|
||||
# reject_reply :boolean default(FALSE), not null
|
||||
# reject_send_not_public_searchability :boolean default(FALSE), not null
|
||||
# reject_send_unlisted_dissubscribable :boolean default(FALSE), not null
|
||||
# reject_send_public_unlisted :boolean default(FALSE), not null
|
||||
# reject_send_dissubscribable :boolean default(FALSE), not null
|
||||
# reject_send_media :boolean default(FALSE), not null
|
||||
# reject_send_sensitive :boolean default(FALSE), not null
|
||||
# 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
|
||||
|
@ -29,8 +42,8 @@ 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]) }
|
||||
scope :with_limitations, -> { where(severity: [:silence, :suspend]).or(where(reject_media: true)) }
|
||||
scope :with_user_facing_limitations, -> { 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')) }
|
||||
|
||||
def to_log_human_identifier
|
||||
|
@ -41,7 +54,21 @@ class DomainBlock < ApplicationRecord
|
|||
if suspend?
|
||||
[:suspend]
|
||||
else
|
||||
[severity.to_sym, reject_media? ? :reject_media : nil, reject_reports? ? :reject_reports : nil].reject { |policy| policy == :noop || policy.nil? }
|
||||
[severity.to_sym,
|
||||
reject_media? ? :reject_media : nil,
|
||||
reject_favourite? ? :reject_favourite : nil,
|
||||
reject_reply? ? :reject_reply : nil,
|
||||
reject_send_not_public_searchability? ? :reject_send_not_public_searchability : nil,
|
||||
reject_send_unlisted_dissubscribable? ? :reject_send_unlisted_dissubscribable : nil,
|
||||
reject_send_public_unlisted? ? :reject_send_public_unlisted : nil,
|
||||
reject_send_dissubscribable? ? :reject_send_dissubscribable : nil,
|
||||
reject_send_media? ? :reject_send_media : nil,
|
||||
reject_send_sensitive? ? :reject_send_sensitive : nil,
|
||||
reject_hashtag? ? :reject_hashtag : nil,
|
||||
reject_straight_follow? ? :reject_straight_follow : nil,
|
||||
reject_new_follow? ? :reject_new_follow : nil,
|
||||
reject_reports? ? :reject_reports : nil
|
||||
].reject { |policy| policy == :noop || policy.nil? }
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -58,6 +85,26 @@ class DomainBlock < ApplicationRecord
|
|||
!!rule_for(domain)&.reject_media?
|
||||
end
|
||||
|
||||
def reject_favourite?(domain)
|
||||
!!rule_for(domain)&.reject_favourite?
|
||||
end
|
||||
|
||||
def reject_reply?(domain)
|
||||
!!rule_for(domain)&.reject_reply?
|
||||
end
|
||||
|
||||
def reject_hashtag?(domain)
|
||||
!!rule_for(domain)&.reject_hashtag?
|
||||
end
|
||||
|
||||
def reject_straight_follow?(domain)
|
||||
!!rule_for(domain)&.reject_straight_follow?
|
||||
end
|
||||
|
||||
def reject_new_follow?(domain)
|
||||
!!rule_for(domain)&.reject_new_follow?
|
||||
end
|
||||
|
||||
def reject_reports?(domain)
|
||||
!!rule_for(domain)&.reject_reports?
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue