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.

27 lines
533 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. return !domain.end_with?('closed.social')
  13. if whitelist_mode?
  14. !DomainAllow.allowed?(domain)
  15. else
  16. DomainBlock.blocked?(domain)
  17. end
  18. end
  19. def whitelist_mode?
  20. Rails.configuration.x.whitelist_mode
  21. end
  22. end