From 0da767f56830a32b73307b2cd1e0608faddddf76 Mon Sep 17 00:00:00 2001 From: Badlop Date: Mon, 29 Apr 2024 17:17:06 +0200 Subject: [PATCH] ban_account/unban: When mod_private is disabled, return meaningful error (#4201) --- src/mod_admin_extra.erl | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/mod_admin_extra.erl b/src/mod_admin_extra.erl index e5e5df357..8616bdd24 100644 --- a/src/mod_admin_extra.erl +++ b/src/mod_admin_extra.erl @@ -1069,11 +1069,16 @@ prepare_reason(Reason) when is_binary(Reason) -> %% Ban account v2 ban_account_v2(User, Host, ReasonText) -> - case is_banned(User, Host) of - true -> - account_was_already_banned; + case gen_mod:is_loaded(Host, mod_private) of false -> - ban_account_v2_b(User, Host, ReasonText) + mod_private_is_required_but_disabled; + true -> + case is_banned(User, Host) of + true -> + account_was_already_banned; + false -> + ban_account_v2_b(User, Host, ReasonText) + end end. ban_account_v2_b(User, Host, ReasonText) -> @@ -1161,11 +1166,16 @@ is_banned(User, Host) -> %% Unban account unban_account(User, Host) -> - case is_banned(User, Host) of + case gen_mod:is_loaded(Host, mod_private) of false -> - account_was_not_banned; + mod_private_is_required_but_disabled; true -> - unban_account2(User, Host) + case is_banned(User, Host) of + false -> + account_was_not_banned; + true -> + unban_account2(User, Host) + end end. unban_account2(User, Host) ->