2021-12-18 07:02:14 +09:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'concurrent'
|
2023-05-24 18:55:40 +09:00
|
|
|
require_relative 'base'
|
2021-12-18 07:02:14 +09:00
|
|
|
|
2023-05-23 23:08:26 +09:00
|
|
|
module Mastodon::CLI
|
2023-05-24 18:55:40 +09:00
|
|
|
class CanonicalEmailBlocks < Base
|
2021-12-18 07:02:14 +09: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 10:31:54 +09:00
|
|
|
This command can be used to find whether a known email address is blocked.
|
2021-12-18 07:02:14 +09:00
|
|
|
LONG_DESC
|
|
|
|
def find(email)
|
2022-08-28 10:31:54 +09:00
|
|
|
accts = CanonicalEmailBlock.matching_email(email)
|
|
|
|
|
2021-12-18 07:02:14 +09:00
|
|
|
if accts.empty?
|
2022-08-28 10:31:54 +09:00
|
|
|
say("#{email} is not blocked", :green)
|
2021-12-18 07:02:14 +09:00
|
|
|
else
|
2022-08-28 10:31:54 +09:00
|
|
|
say("#{email} is blocked", :red)
|
2021-12-18 07:02:14 +09: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 10:31:54 +09:00
|
|
|
blocks = CanonicalEmailBlock.matching_email(email)
|
|
|
|
|
2021-12-18 07:02:14 +09:00
|
|
|
if blocks.empty?
|
2022-08-28 10:31:54 +09:00
|
|
|
say("#{email} is not blocked", :green)
|
2021-12-18 07:02:14 +09:00
|
|
|
else
|
|
|
|
blocks.destroy_all
|
2022-08-28 10:31:54 +09:00
|
|
|
say("Unblocked #{email}", :green)
|
2021-12-18 07:02:14 +09:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|