Software /
code /
prosody
Comparison
plugins/muc/mod_muc.lua @ 1741:2919f3b985fc
MUC: Added support for generating unique room names
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Mon, 07 Sep 2009 20:29:04 +0500 |
parent | 1738:ee4a7151ed07 |
child | 1747:28e5f6b535a8 |
comparison
equal
deleted
inserted
replaced
1740:b37ccf9bec89 | 1741:2919f3b985fc |
---|---|
18 local muc_new_room = module:require "muc".new_room; | 18 local muc_new_room = module:require "muc".new_room; |
19 local register_component = require "core.componentmanager".register_component; | 19 local register_component = require "core.componentmanager".register_component; |
20 local deregister_component = require "core.componentmanager".deregister_component; | 20 local deregister_component = require "core.componentmanager".deregister_component; |
21 local jid_split = require "util.jid".split; | 21 local jid_split = require "util.jid".split; |
22 local st = require "util.stanza"; | 22 local st = require "util.stanza"; |
23 local uuid_gen = require "util.uuid".generate; | |
23 | 24 |
24 local rooms = {}; | 25 local rooms = {}; |
25 local component; | 26 local component; |
26 local host_room = muc_new_room(muc_host); | 27 local host_room = muc_new_room(muc_host); |
27 host_room.route_stanza = function(room, stanza) core_post_stanza(component, stanza); end; | 28 host_room.route_stanza = function(room, stanza) core_post_stanza(component, stanza); end; |
46 local xmlns = stanza.tags[1].attr.xmlns; | 47 local xmlns = stanza.tags[1].attr.xmlns; |
47 if xmlns == "http://jabber.org/protocol/disco#info" then | 48 if xmlns == "http://jabber.org/protocol/disco#info" then |
48 origin.send(get_disco_info(stanza)); | 49 origin.send(get_disco_info(stanza)); |
49 elseif xmlns == "http://jabber.org/protocol/disco#items" then | 50 elseif xmlns == "http://jabber.org/protocol/disco#items" then |
50 origin.send(get_disco_items(stanza)); | 51 origin.send(get_disco_items(stanza)); |
52 elseif xmlns == "http://jabber.org/protocol/muc#unique" then | |
53 origin.send(st.reply(stanza):tag("unique", {xmlns = xmlns}):text(uuid_gen())); -- FIXME Random UUIDs can theoretically have collisions | |
51 else | 54 else |
52 origin.send(st.error_reply(stanza, "cancel", "service-unavailable")); -- TODO disco/etc | 55 origin.send(st.error_reply(stanza, "cancel", "service-unavailable")); -- TODO disco/etc |
53 end | 56 end |
54 else | 57 else |
55 host_room:handle_stanza(origin, stanza); | 58 host_room:handle_stanza(origin, stanza); |