-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,
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, <<URL/binary, $/, Room/binary, $@, Host/binary>>};
+ room_name ->
+ {ok, <<URL/binary, $/, Room/binary>>}
+ end
+ end.
+
depends(_Host, _Opts) ->
[{mod_muc, hard}].
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(
{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},
{outdir, <<"www/muc">>},
{spam_prevention, true},
{timezone, local},
+ {url, undefined},
{top_link, {<<"/">>, <<"Home">>}}].
-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) ->
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).
+
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()}.