include Attachmentable
include Paginable
include AccountCounters
+ include DomainNormalizable
enum protocol: [:ostatus, :activitypub]
end
before_create :generate_keys
- before_validation :normalize_domain
before_validation :prepare_contents, if: :local?
before_destroy :clean_feed_manager
def normalize_domain
return if local?
- self.domain = TagManager.instance.normalize_domain(domain)
+ super
end
def emojifiable_text
--- /dev/null
+# frozen_string_literal: true
+
+module DomainNormalizable
+ extend ActiveSupport::Concern
+
+ included do
+ before_validation :normalize_domain
+ end
+
+ private
+
+ def normalize_domain
+ self.domain = TagManager.instance.normalize_domain(domain)
+ end
+end
#
class DomainBlock < ApplicationRecord
+ include DomainNormalizable
+
enum severity: [:silence, :suspend, :noop]
attr_accessor :retroactive
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
#
class EmailDomainBlock < ApplicationRecord
- before_validation :normalize_domain
+ include DomainNormalizable
validates :domain, presence: true, uniqueness: true
where(domain: domain).exists?
end
-
- private
-
- def normalize_domain
- self.domain = TagManager.instance.normalize_domain(domain)
- end
end