fixed wrong reqbody for delete, added explicit slot_type also for upload request, variable misspelling corrected

This commit is contained in:
steckbrief 2016-08-21 12:08:35 +02:00
parent 25e8420fdb
commit 15090fe1be

View file

@ -59,7 +59,7 @@ module:hook("iq/host/"..xmlns_http_upload..":request", function (event)
local content_type = request:get_child_text("content-type"); local content_type = request:get_child_text("content-type");
-- build the body -- build the body
local reqbody = "xmpp_server_key=" .. xmpp_server_key .. "&size=" .. filesize .. "&filename=" .. filename .. "&user_jid=" .. orig_from; local reqbody = "xmpp_server_key=" .. xmpp_server_key .. "&slot_type=upload&size=" .. filesize .. "&filename=" .. filename .. "&user_jid=" .. orig_from;
if content_type then if content_type then
reqbody = reqbody .. "&content_type=" .. content_type; reqbody = reqbody .. "&content_type=" .. content_type;
end end
@ -142,7 +142,7 @@ module:hook("iq/host/"..xmlns_http_upload..":request", function (event)
return true; return true;
end end
-- build the body -- build the body
local reqbody = "xmpp_server_key=" .. xmpp_server_key .. "&size=" .. filesize .. "&filename=" .. filename .. "&user_jid=" .. orig_from; local reqbody = "xmpp_server_key=" .. xmpp_server_key .. "slot_type=delete&file_url=" .. fileurl .. "&user_jid=" .. orig_from;
-- the request -- the request
local respbody, statuscode = http.request(external_url, reqbody); local respbody, statuscode = http.request(external_url, reqbody);
respbody = string.gsub(respbody, "\\/", "/") respbody = string.gsub(respbody, "\\/", "/")
@ -194,7 +194,7 @@ module:hook("iq/host/"..xmlns_http_upload..":request", function (event)
local reply = st.reply(stanza); local reply = st.reply(stanza);
reply:tag("slot", { xmlns = xmlns_http_upload }); reply:tag("slot", { xmlns = xmlns_http_upload });
reply:tag("deletetoken"):text(deletetoken):up(); reply:tag("deletetoken"):text(delete_token):up();
origin.send(reply); origin.send(reply);
else else
origin.send(st.error_reply(stanza, "cancel", "undefined-condition", "status code: " .. statuscode .. " response: " ..respbody)); origin.send(st.error_reply(stanza, "cancel", "undefined-condition", "status code: " .. statuscode .. " response: " ..respbody));