闭社主体 forked from https://github.com/tootsuite/mastodon
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
489 B

  1. # frozen_string_literal: true
  2. module DomainControlHelper
  3. def domain_not_allowed?(uri_or_domain)
  4. return if uri_or_domain.blank?
  5. domain = begin
  6. if uri_or_domain.include?('://')
  7. Addressable::URI.parse(uri_or_domain).domain
  8. else
  9. uri_or_domain
  10. end
  11. end
  12. if whitelist_mode?
  13. !DomainAllow.allowed?(domain)
  14. else
  15. DomainBlock.blocked?(domain)
  16. end
  17. end
  18. def whitelist_mode?
  19. Rails.configuration.x.whitelist_mode
  20. end
  21. end