diff --git a/src/mod_muc_log.erl b/src/mod_muc_log.erl index b20d94935..08498869f 100644 --- a/src/mod_muc_log.erl +++ b/src/mod_muc_log.erl @@ -34,7 +34,7 @@ -behaviour(gen_mod). %% API --export([start/2, stop/1, reload/3, +-export([start/2, stop/1, reload/3, get_url/1, check_access_log/2, add_to_log/5]). -export([init/1, handle_call/3, handle_cast/2, @@ -90,6 +90,19 @@ check_access_log(Host, From) -> Res -> Res end. +-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 + undefined -> error; + URL -> + case mod_muc_log_opt:dirname(ServerHost) of + room_jid -> + {ok, <>}; + room_name -> + {ok, <>} + end + end. + depends(_Host, _Opts) -> [{mod_muc, hard}]. @@ -953,6 +966,8 @@ mod_opt_type(spam_prevention) -> econf:bool(); mod_opt_type(timezone) -> econf:enum([local, universal]); +mod_opt_type(url) -> + econf:url(); mod_opt_type(top_link) -> econf:and_then( econf:non_empty( @@ -965,7 +980,7 @@ mod_opt_type(top_link) -> {atom(), any()}]. mod_options(_) -> [{access_log, muc_admin}, - {cssfile, filename:join(misc:css_dir(), <<"muc.css">>)}, + {cssfile, {file, filename:join(misc:css_dir(), <<"muc.css">>)}}, {dirname, room_jid}, {dirtype, subdirs}, {file_format, html}, @@ -973,4 +988,5 @@ mod_options(_) -> {outdir, <<"www/muc">>}, {spam_prevention, true}, {timezone, local}, + {url, undefined}, {top_link, {<<"/">>, <<"Home">>}}]. diff --git a/src/mod_muc_log_opt.erl b/src/mod_muc_log_opt.erl index 1fbad70c1..fb4d0266f 100644 --- a/src/mod_muc_log_opt.erl +++ b/src/mod_muc_log_opt.erl @@ -13,6 +13,7 @@ -export([spam_prevention/1]). -export([timezone/1]). -export([top_link/1]). +-export([url/1]). -spec access_log(gen_mod:opts() | global | binary()) -> 'muc_admin' | acl:acl(). access_log(Opts) when is_map(Opts) -> @@ -74,3 +75,9 @@ top_link(Opts) when is_map(Opts) -> top_link(Host) -> gen_mod:get_module_opt(Host, mod_muc_log, top_link). +-spec url(gen_mod:opts() | global | binary()) -> 'undefined' | binary(). +url(Opts) when is_map(Opts) -> + gen_mod:get_opt(url, Opts); +url(Host) -> + gen_mod:get_module_opt(Host, mod_muc_log, url). + diff --git a/src/mod_muc_room.erl b/src/mod_muc_room.erl index ff1a81845..ea2b069d7 100644 --- a/src/mod_muc_room.erl +++ b/src/mod_muc_room.erl @@ -4113,8 +4113,19 @@ iq_disco_info_extras(Lang, StateData, Static) -> true -> Fs2 end, + Fs4 = case Config#config.logging of + true -> + case mod_muc_log:get_url(StateData) of + {ok, URL} -> + [{logs, URL}|Fs3]; + error -> + Fs3 + end; + false -> + Fs3 + end, #xdata{type = result, - fields = muc_roominfo:encode(Fs3, Lang)}. + fields = muc_roominfo:encode(Fs4, Lang)}. -spec process_iq_disco_items(jid(), iq(), state()) -> {error, stanza_error()} | {result, disco_items()}.