Changeset

4632:52b6901cabb0

mod_adhoc: Always allow at least the "complete" action
author Florian Zeitz <florob@babelmonkeys.de>
date Fri, 13 Apr 2012 00:39:00 +0200
parents 4631:fc5d3b053454
children 4633:92e1a538f8b0 4858:33458e1d84c8
files plugins/adhoc/adhoc.lib.lua
diffstat 1 files changed, 9 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/adhoc/adhoc.lib.lua	Sun Apr 08 04:09:33 2012 +0500
+++ b/plugins/adhoc/adhoc.lib.lua	Fri Apr 13 00:39:00 2012 +0200
@@ -25,6 +25,7 @@
 end
 
 function _M.handle_cmd(command, origin, stanza)
+	local cmdtag, actions;
 	local sessionid = stanza.tags[1].attr.sessionid or uuid.generate();
 	local dataIn = {};
 	dataIn.to = stanza.attr.to;
@@ -58,7 +59,7 @@
 		elseif name == "error" then
 			cmdtag:tag("note", {type="error"}):text(content.message):up();
 		elseif name =="actions" then
-			local actions = st.stanza("actions");
+			actions = st.stanza("actions");
 			for _, action in ipairs(content) do
 				if (action == "prev") or (action == "next") or (action == "complete") then
 					actions:tag(action):up();
@@ -67,7 +68,6 @@
 						'" at node "'..command.node..'" provided an invalid action "'..action..'"');
 				end
 			end
-			cmdtag:add_child(actions);
 		elseif name == "form" then
 			cmdtag:add_child((content.layout or content):form(content.values));
 		elseif name == "result" then
@@ -76,6 +76,13 @@
 			cmdtag:add_child(content);
 		end
 	end
+
+	if not actions then
+		actions = st.stanza("actions");
+		actions:tag("complete"):up();
+	end
+	cmdtag:add_child(actions);
+
 	stanza:add_child(cmdtag);
 	origin.send(stanza);