mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-24 16:23:40 +01:00
Improve muc#roominfo and muc#roomconfig forms
Now 'muc#roominfo_contactjid' and 'muc#roominfo_pubsub' fields are returned within muc#roominfo form. Also, both 'muc#roominfo_pubsub' and 'muc#roomconfig_pubsub' are now validated.
This commit is contained in:
parent
783ebd1080
commit
10edbe3e09
@ -64,7 +64,8 @@
|
|||||||
logging = false :: boolean(),
|
logging = false :: boolean(),
|
||||||
vcard = <<"">> :: binary(),
|
vcard = <<"">> :: binary(),
|
||||||
captcha_whitelist = (?SETS):empty() :: ?TGB_SET,
|
captcha_whitelist = (?SETS):empty() :: ?TGB_SET,
|
||||||
mam = false :: boolean()
|
mam = false :: boolean(),
|
||||||
|
pubsub = <<"">> :: binary()
|
||||||
}).
|
}).
|
||||||
|
|
||||||
-type config() :: #config{}.
|
-type config() :: #config{}.
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
{fast_tls, ".*", {git, "https://github.com/processone/fast_tls", {tag, "1.0.17"}}},
|
{fast_tls, ".*", {git, "https://github.com/processone/fast_tls", {tag, "1.0.17"}}},
|
||||||
{stringprep, ".*", {git, "https://github.com/processone/stringprep", {tag, "1.0.10"}}},
|
{stringprep, ".*", {git, "https://github.com/processone/stringprep", {tag, "1.0.10"}}},
|
||||||
{fast_xml, ".*", {git, "https://github.com/processone/fast_xml", {tag, "1.1.25"}}},
|
{fast_xml, ".*", {git, "https://github.com/processone/fast_xml", {tag, "1.1.25"}}},
|
||||||
{xmpp, ".*", {git, "https://github.com/processone/xmpp", {tag, "1.1.16"}}},
|
{xmpp, ".*", {git, "https://github.com/processone/xmpp", "a893ee1"}},
|
||||||
{fast_yaml, ".*", {git, "https://github.com/processone/fast_yaml", {tag, "1.0.12"}}},
|
{fast_yaml, ".*", {git, "https://github.com/processone/fast_yaml", {tag, "1.0.12"}}},
|
||||||
{jiffy, ".*", {git, "https://github.com/davisp/jiffy", {tag, "0.14.8"}}},
|
{jiffy, ".*", {git, "https://github.com/davisp/jiffy", {tag, "0.14.8"}}},
|
||||||
{p1_oauth2, ".*", {git, "https://github.com/processone/p1_oauth2", {tag, "0.6.2"}}},
|
{p1_oauth2, ".*", {git, "https://github.com/processone/p1_oauth2", {tag, "0.6.2"}}},
|
||||||
|
@ -1242,6 +1242,17 @@ expulse_participant(Packet, From, StateData, Reason1) ->
|
|||||||
end,
|
end,
|
||||||
remove_online_user(From, NewState).
|
remove_online_user(From, NewState).
|
||||||
|
|
||||||
|
-spec get_owners(state()) -> [jid:jid()].
|
||||||
|
get_owners(StateData) ->
|
||||||
|
?DICT:fold(
|
||||||
|
fun(LJID, owner, Acc) ->
|
||||||
|
[jid:make(LJID)|Acc];
|
||||||
|
(LJID, {owner, _}, Acc) ->
|
||||||
|
[jid:make(LJID)|Acc];
|
||||||
|
(_, _, Acc) ->
|
||||||
|
Acc
|
||||||
|
end, [], StateData#state.affiliations).
|
||||||
|
|
||||||
-spec set_affiliation(jid(), affiliation(), state()) -> state().
|
-spec set_affiliation(jid(), affiliation(), state()) -> state().
|
||||||
set_affiliation(JID, Affiliation, StateData) ->
|
set_affiliation(JID, Affiliation, StateData) ->
|
||||||
set_affiliation(JID, Affiliation, StateData, <<"">>).
|
set_affiliation(JID, Affiliation, StateData, <<"">>).
|
||||||
@ -3196,7 +3207,8 @@ get_config(Lang, StateData, From) ->
|
|||||||
{allow_visitor_nickchange, Config#config.allow_visitor_nickchange},
|
{allow_visitor_nickchange, Config#config.allow_visitor_nickchange},
|
||||||
{allow_voice_requests, Config#config.allow_voice_requests},
|
{allow_voice_requests, Config#config.allow_voice_requests},
|
||||||
{allow_subscription, Config#config.allow_subscription},
|
{allow_subscription, Config#config.allow_subscription},
|
||||||
{voice_request_min_interval, Config#config.voice_request_min_interval}]
|
{voice_request_min_interval, Config#config.voice_request_min_interval},
|
||||||
|
{pubsub, Config#config.pubsub}]
|
||||||
++
|
++
|
||||||
case ejabberd_captcha:is_feature_available() of
|
case ejabberd_captcha:is_feature_available() of
|
||||||
true -> [{captcha_protected, Config#config.captcha_protected}];
|
true -> [{captcha_protected, Config#config.captcha_protected}];
|
||||||
@ -3278,6 +3290,7 @@ set_config(Opts, Config, ServerHost, Lang) ->
|
|||||||
({whois, anyone}, C) -> C#config{anonymous = false};
|
({whois, anyone}, C) -> C#config{anonymous = false};
|
||||||
({maxusers, V}, C) -> C#config{max_users = V};
|
({maxusers, V}, C) -> C#config{max_users = V};
|
||||||
({enablelogging, V}, C) -> C#config{logging = V};
|
({enablelogging, V}, C) -> C#config{logging = V};
|
||||||
|
({pubsub, V}, C) -> C#config{pubsub = V};
|
||||||
({captcha_whitelist, Js}, C) ->
|
({captcha_whitelist, Js}, C) ->
|
||||||
LJIDs = [jid:tolower(J) || J <- Js],
|
LJIDs = [jid:tolower(J) || J <- Js],
|
||||||
C#config{captcha_whitelist = ?SETS:from_list(LJIDs)};
|
C#config{captcha_whitelist = ?SETS:from_list(LJIDs)};
|
||||||
@ -3482,6 +3495,9 @@ set_opts([{Opt, Val} | Opts], StateData) ->
|
|||||||
StateData#state{config =
|
StateData#state{config =
|
||||||
(StateData#state.config)#config{vcard =
|
(StateData#state.config)#config{vcard =
|
||||||
Val}};
|
Val}};
|
||||||
|
pubsub ->
|
||||||
|
StateData#state{config =
|
||||||
|
(StateData#state.config)#config{pubsub = Val}};
|
||||||
allow_subscription ->
|
allow_subscription ->
|
||||||
StateData#state{config =
|
StateData#state{config =
|
||||||
(StateData#state.config)#config{allow_subscription = Val}};
|
(StateData#state.config)#config{allow_subscription = Val}};
|
||||||
@ -3548,6 +3564,7 @@ make_opts(StateData) ->
|
|||||||
?MAKE_CONFIG_OPT(#config.presence_broadcast),
|
?MAKE_CONFIG_OPT(#config.presence_broadcast),
|
||||||
?MAKE_CONFIG_OPT(#config.voice_request_min_interval),
|
?MAKE_CONFIG_OPT(#config.voice_request_min_interval),
|
||||||
?MAKE_CONFIG_OPT(#config.vcard),
|
?MAKE_CONFIG_OPT(#config.vcard),
|
||||||
|
?MAKE_CONFIG_OPT(#config.pubsub),
|
||||||
{captcha_whitelist,
|
{captcha_whitelist,
|
||||||
(?SETS):to_list((StateData#state.config)#config.captcha_whitelist)},
|
(?SETS):to_list((StateData#state.config)#config.captcha_whitelist)},
|
||||||
{affiliations,
|
{affiliations,
|
||||||
@ -3629,10 +3646,17 @@ process_iq_disco_info(_From, #iq{type = get, lang = Lang}, StateData) ->
|
|||||||
|
|
||||||
-spec iq_disco_info_extras(binary(), state()) -> xdata().
|
-spec iq_disco_info_extras(binary(), state()) -> xdata().
|
||||||
iq_disco_info_extras(Lang, StateData) ->
|
iq_disco_info_extras(Lang, StateData) ->
|
||||||
Fs = [{description, (StateData#state.config)#config.description},
|
Fs1 = [{description, (StateData#state.config)#config.description},
|
||||||
{occupants, ?DICT:size(StateData#state.users)}],
|
{occupants, ?DICT:size(StateData#state.users)},
|
||||||
|
{contactjid, get_owners(StateData)}],
|
||||||
|
Fs2 = case (StateData#state.config)#config.pubsub of
|
||||||
|
Node when is_binary(Node), Node /= <<"">> ->
|
||||||
|
[{pubsub, Node}|Fs1];
|
||||||
|
_ ->
|
||||||
|
Fs1
|
||||||
|
end,
|
||||||
#xdata{type = result,
|
#xdata{type = result,
|
||||||
fields = muc_roominfo:encode(Fs, Lang)}.
|
fields = muc_roominfo:encode(Fs2, 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