canonical_email_blocks.rb 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. # frozen_string_literal: true
  2. require 'concurrent'
  3. require_relative 'base'
  4. module Mastodon::CLI
  5. class CanonicalEmailBlocks < Base
  6. desc 'find EMAIL', 'Find a given e-mail address in the canonical e-mail blocks'
  7. long_desc <<-LONG_DESC
  8. When suspending a local user, a hash of a "canonical" version of their e-mail
  9. address is stored to prevent them from signing up again.
  10. This command can be used to find whether a known email address is blocked.
  11. LONG_DESC
  12. def find(email)
  13. accts = CanonicalEmailBlock.matching_email(email)
  14. if accts.empty?
  15. say("#{email} is not blocked", :green)
  16. else
  17. say("#{email} is blocked", :red)
  18. end
  19. end
  20. desc 'remove EMAIL', 'Remove a canonical e-mail block'
  21. long_desc <<-LONG_DESC
  22. When suspending a local user, a hash of a "canonical" version of their e-mail
  23. address is stored to prevent them from signing up again.
  24. This command allows removing a canonical email block.
  25. LONG_DESC
  26. def remove(email)
  27. blocks = CanonicalEmailBlock.matching_email(email)
  28. if blocks.empty?
  29. say("#{email} is not blocked", :green)
  30. else
  31. blocks.destroy_all
  32. say("Unblocked #{email}", :green)
  33. end
  34. end
  35. end
  36. end