mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-20 16:15:59 +01:00
Advertise muc#roominfo_logs in disco#info of the room
The commit adds new `url` option for mod_muc_log. Fixes #3040
This commit is contained in:
parent
d2f92eecd4
commit
47d0eed3f1
@ -34,7 +34,7 @@
|
|||||||
-behaviour(gen_mod).
|
-behaviour(gen_mod).
|
||||||
|
|
||||||
%% API
|
%% 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]).
|
check_access_log/2, add_to_log/5]).
|
||||||
|
|
||||||
-export([init/1, handle_call/3, handle_cast/2,
|
-export([init/1, handle_call/3, handle_cast/2,
|
||||||
@ -90,6 +90,19 @@ check_access_log(Host, From) ->
|
|||||||
Res -> Res
|
Res -> Res
|
||||||
end.
|
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) ->
|
depends(_Host, _Opts) ->
|
||||||
[{mod_muc, hard}].
|
[{mod_muc, hard}].
|
||||||
|
|
||||||
@ -953,6 +966,8 @@ mod_opt_type(spam_prevention) ->
|
|||||||
econf:bool();
|
econf:bool();
|
||||||
mod_opt_type(timezone) ->
|
mod_opt_type(timezone) ->
|
||||||
econf:enum([local, universal]);
|
econf:enum([local, universal]);
|
||||||
|
mod_opt_type(url) ->
|
||||||
|
econf:url();
|
||||||
mod_opt_type(top_link) ->
|
mod_opt_type(top_link) ->
|
||||||
econf:and_then(
|
econf:and_then(
|
||||||
econf:non_empty(
|
econf:non_empty(
|
||||||
@ -965,7 +980,7 @@ mod_opt_type(top_link) ->
|
|||||||
{atom(), any()}].
|
{atom(), any()}].
|
||||||
mod_options(_) ->
|
mod_options(_) ->
|
||||||
[{access_log, muc_admin},
|
[{access_log, muc_admin},
|
||||||
{cssfile, filename:join(misc:css_dir(), <<"muc.css">>)},
|
{cssfile, {file, filename:join(misc:css_dir(), <<"muc.css">>)}},
|
||||||
{dirname, room_jid},
|
{dirname, room_jid},
|
||||||
{dirtype, subdirs},
|
{dirtype, subdirs},
|
||||||
{file_format, html},
|
{file_format, html},
|
||||||
@ -973,4 +988,5 @@ mod_options(_) ->
|
|||||||
{outdir, <<"www/muc">>},
|
{outdir, <<"www/muc">>},
|
||||||
{spam_prevention, true},
|
{spam_prevention, true},
|
||||||
{timezone, local},
|
{timezone, local},
|
||||||
|
{url, undefined},
|
||||||
{top_link, {<<"/">>, <<"Home">>}}].
|
{top_link, {<<"/">>, <<"Home">>}}].
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
-export([spam_prevention/1]).
|
-export([spam_prevention/1]).
|
||||||
-export([timezone/1]).
|
-export([timezone/1]).
|
||||||
-export([top_link/1]).
|
-export([top_link/1]).
|
||||||
|
-export([url/1]).
|
||||||
|
|
||||||
-spec access_log(gen_mod:opts() | global | binary()) -> 'muc_admin' | acl:acl().
|
-spec access_log(gen_mod:opts() | global | binary()) -> 'muc_admin' | acl:acl().
|
||||||
access_log(Opts) when is_map(Opts) ->
|
access_log(Opts) when is_map(Opts) ->
|
||||||
@ -74,3 +75,9 @@ top_link(Opts) when is_map(Opts) ->
|
|||||||
top_link(Host) ->
|
top_link(Host) ->
|
||||||
gen_mod:get_module_opt(Host, mod_muc_log, top_link).
|
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).
|
||||||
|
|
||||||
|
@ -4113,8 +4113,19 @@ iq_disco_info_extras(Lang, StateData, Static) ->
|
|||||||
true ->
|
true ->
|
||||||
Fs2
|
Fs2
|
||||||
end,
|
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,
|
#xdata{type = result,
|
||||||
fields = muc_roominfo:encode(Fs3, Lang)}.
|
fields = muc_roominfo:encode(Fs4, Lang)}.
|
||||||
|
|
||||||
-spec process_iq_disco_items(jid(), iq(), state()) ->
|
-spec process_iq_disco_items(jid(), iq(), state()) ->
|
||||||
{error, stanza_error()} | {result, disco_items()}.
|
{error, stanza_error()} | {result, disco_items()}.
|
||||||
|
Loading…
Reference in New Issue
Block a user