Comparison

plugins/adhoc/adhoc.lib.lua @ 5758:ebc074918173

adhoc.lib: Don't build error reply from reply stanza
author Kim Alvefur <zash@zash.se>
date Wed, 24 Jul 2013 21:49:36 +0200
parent 5075:4d939d2b1574
child 6302:76699a0ae4c4
comparison
equal deleted inserted replaced
5757:b5ba004beb0a 5758:ebc074918173
32 dataIn.action = stanza.tags[1].attr.action or "execute"; 32 dataIn.action = stanza.tags[1].attr.action or "execute";
33 dataIn.form = stanza.tags[1]:child_with_ns("jabber:x:data"); 33 dataIn.form = stanza.tags[1]:child_with_ns("jabber:x:data");
34 34
35 local data, state = command:handler(dataIn, states[sessionid]); 35 local data, state = command:handler(dataIn, states[sessionid]);
36 states[sessionid] = state; 36 states[sessionid] = state;
37 local stanza = st.reply(stanza);
38 local cmdtag; 37 local cmdtag;
39 if data.status == "completed" then 38 if data.status == "completed" then
40 states[sessionid] = nil; 39 states[sessionid] = nil;
41 cmdtag = command:cmdtag("completed", sessionid); 40 cmdtag = command:cmdtag("completed", sessionid);
42 elseif data.status == "canceled" then 41 elseif data.status == "canceled" then
43 states[sessionid] = nil; 42 states[sessionid] = nil;
44 cmdtag = command:cmdtag("canceled", sessionid); 43 cmdtag = command:cmdtag("canceled", sessionid);
45 elseif data.status == "error" then 44 elseif data.status == "error" then
46 states[sessionid] = nil; 45 states[sessionid] = nil;
47 stanza = st.error_reply(stanza, data.error.type, data.error.condition, data.error.message); 46 local reply = st.error_reply(stanza, data.error.type, data.error.condition, data.error.message);
48 origin.send(stanza); 47 origin.send(reply);
49 return true; 48 return true;
50 else 49 else
51 cmdtag = command:cmdtag("executing", sessionid); 50 cmdtag = command:cmdtag("executing", sessionid);
52 data.actions = data.actions or { "complete" }; 51 data.actions = data.actions or { "complete" };
53 end 52 end
76 cmdtag:add_child((content.layout or content):form(content.values, "result")); 75 cmdtag:add_child((content.layout or content):form(content.values, "result"));
77 elseif name == "other" then 76 elseif name == "other" then
78 cmdtag:add_child(content); 77 cmdtag:add_child(content);
79 end 78 end
80 end 79 end
81 stanza:add_child(cmdtag); 80 local reply = st.reply(stanza);
82 origin.send(stanza); 81 reply:add_child(cmdtag);
82 origin.send(reply);
83 83
84 return true; 84 return true;
85 end 85 end
86 86
87 return _M; 87 return _M;