mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-24 16:23:40 +01:00
Add support for serving a Unique Room Name (thanks to Pablo Polvorin)(EJAB-1121)
SVN Revision: 2802
This commit is contained in:
parent
65aed47873
commit
79be929d96
@ -47,6 +47,7 @@
|
||||
-define(NS_MUC_USER, "http://jabber.org/protocol/muc#user").
|
||||
-define(NS_MUC_ADMIN, "http://jabber.org/protocol/muc#admin").
|
||||
-define(NS_MUC_OWNER, "http://jabber.org/protocol/muc#owner").
|
||||
-define(NS_MUC_UNIQUE, "http://jabber.org/protocol/muc#unique").
|
||||
-define(NS_PUBSUB, "http://jabber.org/protocol/pubsub").
|
||||
-define(NS_PUBSUB_EVENT, "http://jabber.org/protocol/pubsub#event").
|
||||
-define(NS_PUBSUB_OWNER, "http://jabber.org/protocol/pubsub#owner").
|
||||
|
@ -413,6 +413,17 @@ do_route1(Host, ServerHost, Access, HistorySize, RoomShaper,
|
||||
ejabberd_router:route(To,
|
||||
From,
|
||||
jlib:iq_to_xml(Res));
|
||||
#iq{type = get,
|
||||
xmlns = ?NS_MUC_UNIQUE
|
||||
} = IQ ->
|
||||
Res = IQ#iq{type = result,
|
||||
sub_el =
|
||||
[{xmlelement, "unique",
|
||||
[{"xmlns", ?NS_MUC_UNIQUE}],
|
||||
[iq_get_unique(From)]}]},
|
||||
ejabberd_router:route(To,
|
||||
From,
|
||||
jlib:iq_to_xml(Res));
|
||||
#iq{} ->
|
||||
Err = jlib:make_error_reply(
|
||||
Packet,
|
||||
@ -570,6 +581,7 @@ iq_disco_info(Lang) ->
|
||||
{xmlelement, "feature", [{"var", ?NS_DISCO_INFO}], []},
|
||||
{xmlelement, "feature", [{"var", ?NS_DISCO_ITEMS}], []},
|
||||
{xmlelement, "feature", [{"var", ?NS_MUC}], []},
|
||||
{xmlelement, "feature", [{"var", ?NS_MUC_UNIQUE}], []},
|
||||
{xmlelement, "feature", [{"var", ?NS_REGISTER}], []},
|
||||
{xmlelement, "feature", [{"var", ?NS_RSM}], []},
|
||||
{xmlelement, "feature", [{"var", ?NS_VCARD}], []}].
|
||||
@ -669,6 +681,16 @@ flush() ->
|
||||
{"var", Var}],
|
||||
[{xmlelement, "value", [], [{xmlcdata, Val}]}]}).
|
||||
|
||||
%% @doc Get a pseudo unique Room Name. The Room Name is generated as a hash of
|
||||
%% the requester JID, the local time and a random salt.
|
||||
%%
|
||||
%% "pseudo" because we don't verify that there is not a room
|
||||
%% with the returned Name already created, nor mark the generated Name
|
||||
%% as "already used". But in practice, it is unique enough. See
|
||||
%% http://xmpp.org/extensions/xep-0045.html#createroom-unique
|
||||
iq_get_unique(From) ->
|
||||
{xmlcdata, sha:sha(term_to_binary([From, now(), randoms:get_string()]))}.
|
||||
|
||||
iq_get_register_info(Host, From, Lang) ->
|
||||
{LUser, LServer, _} = jlib:jid_tolower(From),
|
||||
LUS = {LUser, LServer},
|
||||
|
Loading…
Reference in New Issue
Block a user