Support for roomconfig_lang/roominfo_lang
Now room owners are able to set a preferred language for the discussions in the room, so other users can discover rooms based on the language they wish to talk. TODO: the language format should conform to RFC 5646. This check should be implemented in 'xmpp' library. Fixes #2436
This commit is contained in:
parent
52b8226671
commit
0f9db50c8d
|
@ -66,7 +66,8 @@
|
||||||
vcard_xupdate = undefined :: undefined | external | binary(),
|
vcard_xupdate = undefined :: undefined | external | binary(),
|
||||||
captcha_whitelist = (?SETS):empty() :: ?TGB_SET,
|
captcha_whitelist = (?SETS):empty() :: ?TGB_SET,
|
||||||
mam = false :: boolean(),
|
mam = false :: boolean(),
|
||||||
pubsub = <<"">> :: binary()
|
pubsub = <<"">> :: binary(),
|
||||||
|
lang = ?MYLANG :: binary()
|
||||||
}).
|
}).
|
||||||
|
|
||||||
-type config() :: #config{}.
|
-type config() :: #config{}.
|
||||||
|
|
|
@ -976,7 +976,9 @@ mod_opt_type({default_room_options, presence_broadcast}) ->
|
||||||
(participant) -> participant;
|
(participant) -> participant;
|
||||||
(visitor) -> visitor
|
(visitor) -> visitor
|
||||||
end, L)
|
end, L)
|
||||||
end.
|
end;
|
||||||
|
mod_opt_type({default_room_options, lang}) ->
|
||||||
|
fun iolist_to_binary/1.
|
||||||
|
|
||||||
mod_options(Host) ->
|
mod_options(Host) ->
|
||||||
[{access, all},
|
[{access, all},
|
||||||
|
@ -1014,6 +1016,7 @@ mod_options(Host) ->
|
||||||
{allow_visitor_status,true},
|
{allow_visitor_status,true},
|
||||||
{anonymous,true},
|
{anonymous,true},
|
||||||
{captcha_protected,false},
|
{captcha_protected,false},
|
||||||
|
{lang, ?MYLANG},
|
||||||
{logging,false},
|
{logging,false},
|
||||||
{members_by_default,true},
|
{members_by_default,true},
|
||||||
{members_only,false},
|
{members_only,false},
|
||||||
|
|
|
@ -3277,7 +3277,8 @@ get_config(Lang, StateData, From) ->
|
||||||
translate:translate(Lang, <<"Configuration of room ~s">>),
|
translate:translate(Lang, <<"Configuration of room ~s">>),
|
||||||
[jid:encode(StateData#state.jid)]),
|
[jid:encode(StateData#state.jid)]),
|
||||||
Fs = [{roomname, Config#config.title},
|
Fs = [{roomname, Config#config.title},
|
||||||
{roomdesc, Config#config.description}] ++
|
{roomdesc, Config#config.description},
|
||||||
|
{lang, Config#config.lang}] ++
|
||||||
case acl:match_rule(StateData#state.server_host, AccessPersistent, From) of
|
case acl:match_rule(StateData#state.server_host, AccessPersistent, From) of
|
||||||
allow -> [{persistentroom, Config#config.persistent}];
|
allow -> [{persistentroom, Config#config.persistent}];
|
||||||
deny -> []
|
deny -> []
|
||||||
|
@ -3399,6 +3400,7 @@ set_config(Opts, Config, ServerHost, Lang) ->
|
||||||
({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};
|
({pubsub, V}, C) -> C#config{pubsub = V};
|
||||||
|
({lang, L}, C) -> C#config{lang = L};
|
||||||
({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)};
|
||||||
|
@ -3630,6 +3632,9 @@ set_opts([{Opt, Val} | Opts], StateData) ->
|
||||||
allow_subscription ->
|
allow_subscription ->
|
||||||
StateData#state{config =
|
StateData#state{config =
|
||||||
(StateData#state.config)#config{allow_subscription = Val}};
|
(StateData#state.config)#config{allow_subscription = Val}};
|
||||||
|
lang ->
|
||||||
|
StateData#state{config =
|
||||||
|
(StateData#state.config)#config{lang = Val}};
|
||||||
subscribers ->
|
subscribers ->
|
||||||
{Subscribers, Nicks} =
|
{Subscribers, Nicks} =
|
||||||
lists:foldl(
|
lists:foldl(
|
||||||
|
@ -3709,6 +3714,7 @@ make_opts(StateData) ->
|
||||||
?MAKE_CONFIG_OPT(#config.vcard),
|
?MAKE_CONFIG_OPT(#config.vcard),
|
||||||
?MAKE_CONFIG_OPT(#config.vcard_xupdate),
|
?MAKE_CONFIG_OPT(#config.vcard_xupdate),
|
||||||
?MAKE_CONFIG_OPT(#config.pubsub),
|
?MAKE_CONFIG_OPT(#config.pubsub),
|
||||||
|
?MAKE_CONFIG_OPT(#config.lang),
|
||||||
{captcha_whitelist,
|
{captcha_whitelist,
|
||||||
(?SETS):to_list((StateData#state.config)#config.captcha_whitelist)},
|
(?SETS):to_list((StateData#state.config)#config.captcha_whitelist)},
|
||||||
{affiliations,
|
{affiliations,
|
||||||
|
@ -3841,7 +3847,8 @@ process_iq_disco_info(From, #iq{type = get, lang = Lang,
|
||||||
iq_disco_info_extras(Lang, StateData) ->
|
iq_disco_info_extras(Lang, StateData) ->
|
||||||
Fs1 = [{description, (StateData#state.config)#config.description},
|
Fs1 = [{description, (StateData#state.config)#config.description},
|
||||||
{occupants, ?DICT:size(StateData#state.nicks)},
|
{occupants, ?DICT:size(StateData#state.nicks)},
|
||||||
{contactjid, get_owners(StateData)}],
|
{contactjid, get_owners(StateData)},
|
||||||
|
{lang, (StateData#state.config)#config.lang}],
|
||||||
Fs2 = case (StateData#state.config)#config.pubsub of
|
Fs2 = case (StateData#state.config)#config.pubsub of
|
||||||
Node when is_binary(Node), Node /= <<"">> ->
|
Node when is_binary(Node), Node /= <<"">> ->
|
||||||
[{pubsub, Node}|Fs1];
|
[{pubsub, Node}|Fs1];
|
||||||
|
|
Loading…
Reference in New Issue