feat(cli): allow the mobilizon.users.delete command to delete multiple users by email domain or ip

Also allow to delete groups the user's actors are admins of

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2023-08-21 17:51:22 +02:00
parent d29f1e1ee2
commit bc50ab66f3
3 changed files with 190 additions and 16 deletions

View File

@@ -97,6 +97,21 @@ defmodule Mobilizon.Users do
end
end
@spec get_users_by_email_domain(String.t()) :: list(User.t())
def get_users_by_email_domain(email_domain) do
User
|> where([u], like(u.email, ^"%#{email_domain}%"))
|> Repo.all()
end
@spec get_users_by_ip_address(String.t()) :: list(User.t())
def get_users_by_ip_address(ip_address) do
User
|> where([u], u.current_sign_in_ip == ^ip_address)
|> or_where([u], u.last_sign_in_ip == ^ip_address)
|> Repo.all()
end
@doc """
Get an user by its activation token.
"""