mirror of
https://github.com/glitch-soc/mastodon.git
synced 2024-11-24 17:14:15 -05:00
17c591ffba
* Fix #2119 - Whenever about to send a HTTP request, normalize the URI * Add test for IDN request in FetchLinkCardService * Perform IDN normalization on domains before they are stored in the DB
25 lines
541 B
Ruby
25 lines
541 B
Ruby
# frozen_string_literal: true
|
|
|
|
class DomainBlock < ApplicationRecord
|
|
enum severity: [:silence, :suspend]
|
|
|
|
attr_accessor :retroactive
|
|
|
|
validates :domain, presence: true, uniqueness: true
|
|
|
|
has_many :accounts, foreign_key: :domain, primary_key: :domain
|
|
delegate :count, to: :accounts, prefix: true
|
|
|
|
def self.blocked?(domain)
|
|
where(domain: domain, severity: :suspend).exists?
|
|
end
|
|
|
|
before_validation :normalize_domain
|
|
|
|
private
|
|
|
|
def normalize_domain
|
|
self.domain = TagManager.instance.normalize_domain(domain)
|
|
end
|
|
end
|