2021-12-18 00:02:14 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'concurrent'
|
|
|
|
require_relative '../../config/boot'
|
|
|
|
require_relative '../../config/environment'
|
|
|
|
require_relative 'cli_helper'
|
|
|
|
|
|
|
|
module Mastodon
|
|
|
|
class CanonicalEmailBlocksCLI < Thor
|
|
|
|
include CLIHelper
|
|
|
|
|
|
|
|
def self.exit_on_failure?
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
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 04:31:54 +03:00
|
|
|
This command can be used to find whether a known email address is blocked.
|
2021-12-18 00:02:14 +02:00
|
|
|
LONG_DESC
|
|
|
|
def find(email)
|
2022-08-28 04:31:54 +03:00
|
|
|
accts = CanonicalEmailBlock.matching_email(email)
|
|
|
|
|
2021-12-18 00:02:14 +02:00
|
|
|
if accts.empty?
|
2022-08-28 04:31:54 +03:00
|
|
|
say("#{email} is not blocked", :green)
|
2021-12-18 00:02:14 +02:00
|
|
|
else
|
2022-08-28 04:31:54 +03:00
|
|
|
say("#{email} is blocked", :red)
|
2021-12-18 00:02:14 +02: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 04:31:54 +03:00
|
|
|
blocks = CanonicalEmailBlock.matching_email(email)
|
|
|
|
|
2021-12-18 00:02:14 +02:00
|
|
|
if blocks.empty?
|
2022-08-28 04:31:54 +03:00
|
|
|
say("#{email} is not blocked", :green)
|
2021-12-18 00:02:14 +02:00
|
|
|
else
|
|
|
|
blocks.destroy_all
|
2022-08-28 04:31:54 +03:00
|
|
|
say("Unblocked #{email}", :green)
|
2021-12-18 00:02:14 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|