The code powering m.abunchtell.com https://m.abunchtell.com
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 

36 linhas
916 B

  1. # frozen_string_literal: true
  2. # == Schema Information
  3. #
  4. # Table name: domain_blocks
  5. #
  6. # id :integer not null, primary key
  7. # domain :string default(""), not null
  8. # created_at :datetime not null
  9. # updated_at :datetime not null
  10. # severity :integer default("silence")
  11. # reject_media :boolean default(FALSE), not null
  12. #
  13. class DomainBlock < ApplicationRecord
  14. enum severity: [:silence, :suspend, :noop]
  15. attr_accessor :retroactive
  16. validates :domain, presence: true, uniqueness: true
  17. has_many :accounts, foreign_key: :domain, primary_key: :domain
  18. delegate :count, to: :accounts, prefix: true
  19. def self.blocked?(domain)
  20. where(domain: domain, severity: :suspend).exists?
  21. end
  22. before_validation :normalize_domain
  23. private
  24. def normalize_domain
  25. self.domain = TagManager.instance.normalize_domain(domain)
  26. end
  27. end