2021-12-17 22:02:14 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'concurrent'
|
2023-05-24 09:55:40 +00:00
|
|
|
require_relative 'base'
|
2021-12-17 22:02:14 +00:00
|
|
|
|
2023-05-23 14:08:26 +00:00
|
|
|
module Mastodon::CLI
|
2023-05-24 09:55:40 +00:00
|
|
|
class CanonicalEmailBlocks < Base
|
2021-12-17 22:02:14 +00:00
|
|
|
desc 'find EMAIL', 'Find a given e-mail address in the canonical e-mail blocks'
|
|
|
|
long_desc <<-LONG_DESC
|
|
|
|
When suspending a local user, a hash of a "canonical" version of their e-mail
|
|
|
|
address is stored to prevent them from signing up again.
|
|
|
|
|
2022-08-28 01:31:54 +00:00
|
|
|
This command can be used to find whether a known email address is blocked.
|
2021-12-17 22:02:14 +00:00
|
|
|
LONG_DESC
|
|
|
|
def find(email)
|
2022-08-28 01:31:54 +00:00
|
|
|
accts = CanonicalEmailBlock.matching_email(email)
|
|
|
|
|
2021-12-17 22:02:14 +00:00
|
|
|
if accts.empty?
|
2022-08-28 01:31:54 +00:00
|
|
|
say("#{email} is not blocked", :green)
|
2021-12-17 22:02:14 +00:00
|
|
|
else
|
2022-08-28 01:31:54 +00:00
|
|
|
say("#{email} is blocked", :red)
|
2021-12-17 22:02:14 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
desc 'remove EMAIL', 'Remove a canonical e-mail block'
|
|
|
|
long_desc <<-LONG_DESC
|
|
|
|
When suspending a local user, a hash of a "canonical" version of their e-mail
|
|
|
|
address is stored to prevent them from signing up again.
|
|
|
|
|
|
|
|
This command allows removing a canonical email block.
|
|
|
|
LONG_DESC
|
|
|
|
def remove(email)
|
2022-08-28 01:31:54 +00:00
|
|
|
blocks = CanonicalEmailBlock.matching_email(email)
|
|
|
|
|
2021-12-17 22:02:14 +00:00
|
|
|
if blocks.empty?
|
2022-08-28 01:31:54 +00:00
|
|
|
say("#{email} is not blocked", :green)
|
2021-12-17 22:02:14 +00:00
|
|
|
else
|
|
|
|
blocks.destroy_all
|
2022-08-28 01:31:54 +00:00
|
|
|
say("Unblocked #{email}", :green)
|
2021-12-17 22:02:14 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|