From 0e64090732fd5de93488c5cb83771fa6451db93b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Chrz=C4=85szcz?= Date: Thu, 7 Apr 2022 11:37:27 +0200 Subject: [PATCH] Get only existing subhosts for MAM MUC domain removal Previously defaults were used even if MUC(Light) was not enabled. --- src/mam/mod_mam_muc_rdbms_arch.erl | 18 +++++++++++------- src/muc_light/mod_muc_light.erl | 1 - 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/mam/mod_mam_muc_rdbms_arch.erl b/src/mam/mod_mam_muc_rdbms_arch.erl index bf035b6061..9114fc63d3 100644 --- a/src/mam/mod_mam_muc_rdbms_arch.erl +++ b/src/mam/mod_mam_muc_rdbms_arch.erl @@ -327,13 +327,17 @@ remove_domain_trans(HostType, MucHost) -> mongoose_rdbms:execute_successfully(HostType, mam_muc_remove_domain_users, [MucHost]). get_subhosts(HostType, Domain) -> - MucHostPattern = gen_mod:get_module_opt(HostType, mod_muc, host, - mod_muc:default_host()), - LightHostPattern = gen_mod:get_module_opt(HostType, mod_muc_light, host, - mod_muc_light:default_host()), - MucHost = mongoose_subdomain_utils:get_fqdn(MucHostPattern, Domain), - LightHost = mongoose_subdomain_utils:get_fqdn(LightHostPattern, Domain), - lists:usort([MucHost, LightHost]). + lists:usort( + lists:flatmap(fun(Module) -> get_subhosts_for_module(HostType, Domain, Module) end, + [mod_muc, mod_muc_light])). + +get_subhosts_for_module(HostType, Domain, Module) -> + case gen_mod:get_module_opts(HostType, Module) of + #{host := HostPattern} -> + [mongoose_subdomain_utils:get_fqdn(HostPattern, Domain)]; + #{} -> + [] + end. %% GDPR logic extract_gdpr_messages(HostType, SenderID) -> diff --git a/src/muc_light/mod_muc_light.erl b/src/muc_light/mod_muc_light.erl index a26f79be97..594e8d30e6 100644 --- a/src/muc_light/mod_muc_light.erl +++ b/src/muc_light/mod_muc_light.erl @@ -24,7 +24,6 @@ -behaviour(mongoose_module_metrics). %% API --export([default_host/0]). -export([server_host_to_muc_host/2]). -export([config_schema/1]).