Don't crash in mod_muc_log:get_url when mod_muc_log is not enabled

Disco on room can call this function even when logger is not enabled,
but this room option was enabled previously when logger was active.
This commit is contained in:
Paweł Chmielowski 2020-05-15 13:43:56 +02:00
parent e94b89a57d
commit 6f54b6ae3b
1 changed files with 4 additions and 1 deletions

View File

@ -92,7 +92,7 @@ check_access_log(Host, From) ->
-spec get_url(#state{}) -> {ok, binary()} | error.
get_url(#state{room = Room, host = Host, server_host = ServerHost}) ->
case mod_muc_log_opt:url(ServerHost) of
try mod_muc_log_opt:url(ServerHost) of
undefined -> error;
URL ->
case mod_muc_log_opt:dirname(ServerHost) of
@ -101,6 +101,9 @@ get_url(#state{room = Room, host = Host, server_host = ServerHost}) ->
room_name ->
{ok, <<URL/binary, $/, Room/binary>>}
end
catch
error:{module_not_loaded, _, _} ->
error
end.
depends(_Host, _Opts) ->