Skip to content

Commit

Permalink
Get only existing subhosts for MAM MUC domain removal
Browse files Browse the repository at this point in the history
Previously defaults were used even if MUC(Light) was not enabled.
  • Loading branch information
chrzaszcz committed Apr 7, 2022
1 parent a2854d9 commit 0e64090
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
18 changes: 11 additions & 7 deletions src/mam/mod_mam_muc_rdbms_arch.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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) ->
Expand Down
1 change: 0 additions & 1 deletion src/muc_light/mod_muc_light.erl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
-behaviour(mongoose_module_metrics).

%% API
-export([default_host/0]).
-export([server_host_to_muc_host/2]).
-export([config_schema/1]).

Expand Down

0 comments on commit 0e64090

Please sign in to comment.