Diff

mod_adhoc/adhoc/mod_adhoc.lua @ 121:a9898f13c89e

mod_adhoc: Major refactoring. Actuall data exchange happens here now mod_adhoc_cmd_*: Update to work with aforementioned change
author Florian Zeitz <florob@babelmonkeys.de>
date Fri, 22 Jan 2010 04:25:58 +0100
parent 109:9b63fd1196c0
child 125:8111c8a9e1ad
line wrap: on
line diff
--- a/mod_adhoc/adhoc/mod_adhoc.lua	Fri Jan 15 10:17:57 2010 +0100
+++ b/mod_adhoc/adhoc/mod_adhoc.lua	Fri Jan 22 04:25:58 2010 +0100
@@ -6,6 +6,7 @@
 
 local st = require "util.stanza";
 local is_admin = require "core.usermanager".is_admin;
+local adhoc_handle_cmd = module:require "adhoc".handle_cmd;
 local commands = {};
 
 module:add_feature("http://jabber.org/protocol/commands");
@@ -15,7 +16,7 @@
     local privileged = is_admin(event.stanza.attr.from) or is_admin(stanza.attr.from, stanza.attr.to); -- TODO: Is this correct, or should is_admin be changed?
     if stanza.attr.type == "get" and stanza.tags[1].attr.node and stanza.tags[1].attr.node == "http://jabber.org/protocol/commands" then
 		reply = st.reply(stanza);
-		reply:tag("query", {xmlns="http://jabber.org/protocol/disco#items", node="http://jabber.org/protocol/commands"})
+		reply:tag("query", {xmlns="http://jabber.org/protocol/disco#items", node="http://jabber.org/protocol/commands"});
 		for i = 1, #commands do
 			-- module:log("info", "adding command %s", commands[i].name);
 			if (commands[i].permission == "admin" and privileged) or (commands[i].permission == "user") then
@@ -43,7 +44,7 @@
 				return true
 			end
 			-- User has permission now execute the command
-			return commands[i].handler(commands[i], origin, stanza);
+			return adhoc_handle_cmd(commands[i], origin, stanza);
 		end
 	end
     end