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