Possibility to unban a user

#1843
This commit is contained in:
Massedil
2025-09-27 17:54:59 +02:00
parent 2ab57db6a5
commit 9d4a558c1a
7 changed files with 92 additions and 7 deletions

View File

@@ -610,6 +610,28 @@ defmodule Mobilizon.GraphQL.Resolvers.User do
end
end
def unban_account(_parent, %{user_id: user_id}, %{
context: %{
current_user: %User{role: role},
current_actor: %Actor{} = moderator_actor
}
})
when is_moderator(role) do
with %User{disabled: true} = user <- Users.get_user(user_id),
{:ok, %User{} = updated_user} <-
Users.unban_user(user) do
Admin.log_action(moderator_actor, "unsuspend", user)
{:ok, updated_user}
else
%User{disabled: false} ->
{:error, dgettext("errors", "User already enabled")}
end
end
def unban_account(_parent, _args, _resolution) do
{:error, dgettext("errors", "You need to be logged-in and moderator to unban an account")}
end
def delete_account(_parent, %{user_id: user_id}, %{
context: %{
current_user: %User{role: role},