aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorWaqas Hussain <waqas20@gmail.com>2011-09-03 00:37:37 +0500
committerWaqas Hussain <waqas20@gmail.com>2011-09-03 00:37:37 +0500
commit827d473985f251f84aa774b8bbecfa12ab29ef2f (patch)
treebe0a34406a934b1d89ee45c377e753569e07b3e9 /plugins
parent9baee6217ef47311aba7bd5964224229efb8b76e (diff)
downloadprosody-827d473985f251f84aa774b8bbecfa12ab29ef2f.tar.gz
prosody-827d473985f251f84aa774b8bbecfa12ab29ef2f.zip
mod_proxy65: Some more cleanup.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mod_proxy65.lua31
1 files changed, 11 insertions, 20 deletions
diff --git a/plugins/mod_proxy65.lua b/plugins/mod_proxy65.lua
index a2af2769..cb59cb3a 100644
--- a/plugins/mod_proxy65.lua
+++ b/plugins/mod_proxy65.lua
@@ -158,35 +158,25 @@ module.unload = function()
connlisteners.deregister(module.host .. ':proxy65');
end
-local function set_activation(stanza)
- local to, reply;
- local from = stanza.attr.from;
- local query = stanza.tags[1];
- local sid = query.attr.sid;
- if query.tags[1] and query.tags[1].name == "activate" then
- to = query.tags[1][1];
- end
- if from ~= nil and to ~= nil and sid ~= nil then
- reply = st.iq({type="result", from=host, to=from});
- reply.attr.id = stanza.attr.id;
- end
- return reply, from, to, sid;
-end
-
module:hook("iq-set/host/http://jabber.org/protocol/bytestreams:query", function(event)
local origin, stanza = event.origin, event.stanza;
- module:log("debug", "Received activation request from %s", stanza.attr.from);
- local reply, from, to, sid = set_activation(stanza);
- if reply ~= nil and from ~= nil and to ~= nil and sid ~= nil then
+ local query = stanza.tags[1];
+ local sid = query.attr.sid;
+ local from = stanza.attr.from;
+ local to = query:get_child_text("activate");
+
+ module:log("debug", "received activation request from %s", stanza.attr.from);
+ if to and sid then
local sha = sha1(sid .. from .. to, true);
if transfers[sha] == nil then
module:log("error", "transfers[sha]: nil");
+ origin.send(st.error_reply(stanza, "modify", "item-not-found"));
elseif(transfers[sha] ~= nil and transfers[sha].initiator ~= nil and transfers[sha].target ~= nil) then
- origin.send(reply);
transfers[sha].activated = true;
transfers[sha].target:lock_read(false);
transfers[sha].initiator:lock_read(false);
+ origin.send(st.reply(stanza));
else
module:log("debug", "Both parties were not yet connected");
local message = "Neither party is connected to the proxy";
@@ -197,10 +187,11 @@ module:hook("iq-set/host/http://jabber.org/protocol/bytestreams:query", function
end
origin.send(st.error_reply(stanza, "cancel", "not-allowed", message));
end
- return true;
else
module:log("error", "activation failed: sid: %s, initiator: %s, target: %s", tostring(sid), tostring(from), tostring(to));
+ origin.send(st.error_reply(stanza, "modify", "bad-request"));
end
+ return true;
end);
if not connlisteners.register(module.host .. ':proxy65', connlistener) then