# HG changeset patch # User Waqas Hussain # Date 1228402917 -18000 # Node ID cbcadb1a6166f4f79efdba1a110b7f5ba2b26e20 # Parent c24471cadc2c5c55639298ac546df8e8a38170ef Reorder the disco info elements to place always included elements first diff -r c24471cadc2c -r cbcadb1a6166 util/discohelper.lua --- a/util/discohelper.lua Wed Dec 03 18:06:04 2008 +0000 +++ b/util/discohelper.lua Thu Dec 04 20:01:57 2008 +0500 @@ -57,20 +57,8 @@ elseif query.attr.xmlns == "http://jabber.org/protocol/disco#items" then handlers = self.item_handlers; end - local handler = handlers[to]; -- get the handler - if not handler then -- if not found then use default handler - if to_node then - handler = handlers["*defaultnode"]; - else - handler = handlers["*defaulthost"]; - end - end - local found; -- to keep track of any handlers found - if handler then - for _, h in ipairs(handler) do - if h(reply, to, from, node) then found = true; end - end - end + local handler; + local found; -- to keep track of any handlers found if to_node then -- handlers which get called always handler = handlers["*node"]; else @@ -81,6 +69,19 @@ if h(reply, to, from, node) then found = true; end end end + handler = handlers[to]; -- get the handler + if not handler then -- if not found then use default handler + if to_node then + handler = handlers["*defaultnode"]; + else + handler = handlers["*defaulthost"]; + end + end + if handler then + for _, h in ipairs(handler) do + if h(reply, to, from, node) then found = true; end + end + end if found then return reply; end -- return the reply if there was one return st.error_reply(stanza, "cancel", "service-unavailable"); end