comparison plugins/adhoc/adhoc.lib.lua @ 8472:d88dc6827675

adhoc.lib: Rename other variable to avoid name clash [luacheck]
author Kim Alvefur <zash@zash.se>
date Tue, 12 Dec 2017 17:51:12 +0100
parents a6f58305411e
children 421b2f8369fd
comparison
equal deleted inserted replaced
8471:a6f58305411e 8472:d88dc6827675
34 form = cmdtag:get_child("x", "jabber:x:data"); 34 form = cmdtag:get_child("x", "jabber:x:data");
35 }; 35 };
36 36
37 local data, state = command:handler(dataIn, states[sessionid]); 37 local data, state = command:handler(dataIn, states[sessionid]);
38 states[sessionid] = state; 38 states[sessionid] = state;
39 local cmdtag; 39 local cmdreply;
40 if data.status == "completed" then 40 if data.status == "completed" then
41 states[sessionid] = nil; 41 states[sessionid] = nil;
42 cmdtag = command:cmdtag("completed", sessionid); 42 cmdreply = command:cmdtag("completed", sessionid);
43 elseif data.status == "canceled" then 43 elseif data.status == "canceled" then
44 states[sessionid] = nil; 44 states[sessionid] = nil;
45 cmdtag = command:cmdtag("canceled", sessionid); 45 cmdreply = command:cmdtag("canceled", sessionid);
46 elseif data.status == "error" then 46 elseif data.status == "error" then
47 states[sessionid] = nil; 47 states[sessionid] = nil;
48 local reply = st.error_reply(stanza, data.error.type, data.error.condition, data.error.message); 48 local reply = st.error_reply(stanza, data.error.type, data.error.condition, data.error.message);
49 origin.send(reply); 49 origin.send(reply);
50 return true; 50 return true;
51 else 51 else
52 cmdtag = command:cmdtag("executing", sessionid); 52 cmdreply = command:cmdtag("executing", sessionid);
53 data.actions = data.actions or { "complete" }; 53 data.actions = data.actions or { "complete" };
54 end 54 end
55 55
56 for name, content in pairs(data) do 56 for name, content in pairs(data) do
57 if name == "info" then 57 if name == "info" then
58 cmdtag:tag("note", {type="info"}):text(content):up(); 58 cmdreply:tag("note", {type="info"}):text(content):up();
59 elseif name == "warn" then 59 elseif name == "warn" then
60 cmdtag:tag("note", {type="warn"}):text(content):up(); 60 cmdreply:tag("note", {type="warn"}):text(content):up();
61 elseif name == "error" then 61 elseif name == "error" then
62 cmdtag:tag("note", {type="error"}):text(content.message):up(); 62 cmdreply:tag("note", {type="error"}):text(content.message):up();
63 elseif name == "actions" then 63 elseif name == "actions" then
64 local actions = st.stanza("actions", { execute = content.default }); 64 local actions = st.stanza("actions", { execute = content.default });
65 for _, action in ipairs(content) do 65 for _, action in ipairs(content) do
66 if (action == "prev") or (action == "next") or (action == "complete") then 66 if (action == "prev") or (action == "next") or (action == "complete") then
67 actions:tag(action):up(); 67 actions:tag(action):up();
68 else 68 else
69 module:log("error", "Command %q at node %q provided an invalid action %q", 69 module:log("error", "Command %q at node %q provided an invalid action %q",
70 command.name, command.node, action); 70 command.name, command.node, action);
71 end 71 end
72 end 72 end
73 cmdtag:add_child(actions); 73 cmdreply:add_child(actions);
74 elseif name == "form" then 74 elseif name == "form" then
75 cmdtag:add_child((content.layout or content):form(content.values)); 75 cmdreply:add_child((content.layout or content):form(content.values));
76 elseif name == "result" then 76 elseif name == "result" then
77 cmdtag:add_child((content.layout or content):form(content.values, "result")); 77 cmdreply:add_child((content.layout or content):form(content.values, "result"));
78 elseif name == "other" then 78 elseif name == "other" then
79 cmdtag:add_child(content); 79 cmdreply:add_child(content);
80 end 80 end
81 end 81 end
82 local reply = st.reply(stanza); 82 local reply = st.reply(stanza);
83 reply:add_child(cmdtag); 83 reply:add_child(cmdreply);
84 origin.send(reply); 84 origin.send(reply);
85 85
86 return true; 86 return true;
87 end 87 end
88 88