25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-28 16:34:13 +01:00

Fix mod_conversejs crash when mod_register not enabled (#3824)

This commit is contained in:
Badlop 2022-05-23 16:41:19 +02:00
parent 75ffce0417
commit 0e25f8d43e

View File

@ -183,10 +183,19 @@ get_register_options(Server) ->
(_) -> false (_) -> false
end, end,
ejabberd_auth:auth_modules(Server)), ejabberd_auth:auth_modules(Server)),
Modules = mod_register_opt:allow_modules(Server), Modules = get_register_modules(Server),
ModRegisterAllowsMe = (Modules == all) orelse lists:member(?MODULE, Modules), ModRegisterAllowsMe = (Modules == all) orelse lists:member(?MODULE, Modules),
[{<<"allow_registration">>, AuthSupportsRegister and ModRegisterAllowsMe}]. [{<<"allow_registration">>, AuthSupportsRegister and ModRegisterAllowsMe}].
get_register_modules(Server) ->
try mod_register_opt:allow_modules(Server)
catch
error:{module_not_loaded, mod_register, _} ->
?DEBUG("mod_conversejs couldn't get mod_register configuration for "
"vhost ~p: module not loaded in that vhost.", [Server]),
[]
end.
get_extra_options(Host) -> get_extra_options(Host) ->
RawOpts = gen_mod:get_module_opt(Host, ?MODULE, conversejs_options), RawOpts = gen_mod:get_module_opt(Host, ?MODULE, conversejs_options),
lists:map(fun({Name, <<"true">>}) -> {Name, true}; lists:map(fun({Name, <<"true">>}) -> {Name, true};