aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorroot <root@fucktheforce.de>2016-08-22 17:06:11 +0200
committerroot <root@fucktheforce.de>2016-08-22 17:06:11 +0200
commit9827ec6d450b71ade7c19740b46274fff6fbc682 (patch)
tree7b9af7aa53c598c0160dafeb5282e9d1484ef3e0
parentedc0dfc9b528d382d496e21b0efecc0928f91314 (diff)
parent6691b27bd11520a826d4ad5a94449603549854a0 (diff)
Merge branch 'master' of http://git.fucktheforce.de/cgi-bin/git/httpupload
-rw-r--r--prosody-module/mod_http_upload_external/mod_http_upload_external.lua11
-rw-r--r--storage-backend/index.php2
2 files changed, 9 insertions, 4 deletions
diff --git a/prosody-module/mod_http_upload_external/mod_http_upload_external.lua b/prosody-module/mod_http_upload_external/mod_http_upload_external.lua
index 335a9d1..11175ee 100644
--- a/prosody-module/mod_http_upload_external/mod_http_upload_external.lua
+++ b/prosody-module/mod_http_upload_external/mod_http_upload_external.lua
@@ -43,7 +43,8 @@ module:hook("iq/host/"..xmlns_http_upload..":request", function (event)
return true;
end
local slot_type = request.attr.type;
- if not slot_type or slot_type ~= "upload" then
+ module:log("debug", "incoming request is of type " .. slot_type);
+ if not slot_type or slot_type == "upload" then
-- validate
local filename = request:get_child_text("filename");
if not filename then
@@ -74,6 +75,7 @@ module:hook("iq/host/"..xmlns_http_upload..":request", function (event)
-- check the response
if statuscode == 500 then
origin.send(st.error_reply(stanza, "cancel", "service-unavailable", respbody));
+ return true;
elseif statuscode == 406 or statuscode == 400 or statuscode == 403 then
local errobj, pos, err = json.decode(respbody);
if err then
@@ -105,6 +107,7 @@ module:hook("iq/host/"..xmlns_http_upload..":request", function (event)
end
elseif statuscode == 403 and errobj["msg"] ~= nil then
origin.send(st.error_reply(stanza, "cancel", "internal-server-error", errobj.msg));
+ return true;
else
origin.send(st.error_reply(stanza, "cancel", "undefined-condition", "msg or err_code not found"));
return true;
@@ -134,7 +137,7 @@ module:hook("iq/host/"..xmlns_http_upload..":request", function (event)
reply:tag("get"):text(get_url):up();
reply:tag("put"):text(put_url):up();
origin.send(reply);
- elseif slot_type ~= "delete" then
+ elseif slot_type == "delete" then
-- validate
local fileurl = request:get_child_text("fileurl");
if not fileurl then
@@ -142,7 +145,7 @@ module:hook("iq/host/"..xmlns_http_upload..":request", function (event)
return true;
end
-- build the body
- local reqbody = "xmpp_server_key=" .. xmpp_server_key .. "slot_type=delete&file_url=" .. fileurl .. "&user_jid=" .. orig_from;
+ local reqbody = "xmpp_server_key=" .. xmpp_server_key .. "&slot_type=delete&file_url=" .. fileurl .. "&user_jid=" .. orig_from;
-- the request
local respbody, statuscode = http.request(external_url, reqbody);
respbody = string.gsub(respbody, "\\/", "/")
@@ -151,6 +154,7 @@ module:hook("iq/host/"..xmlns_http_upload..":request", function (event)
-- check the response
if statuscode == 500 then
origin.send(st.error_reply(stanza, "cancel", "service-unavailable", respbody));
+ return true;
elseif statuscode == 406 or statuscode == 400 or statuscode == 403 then
local errobj, pos, err = json.decode(respbody);
if err then
@@ -169,6 +173,7 @@ module:hook("iq/host/"..xmlns_http_upload..":request", function (event)
end
elseif statuscode == 403 and errobj["msg"] ~= nil then
origin.send(st.error_reply(stanza, "cancel", "internal-server-error", errobj.msg));
+ return true;
else
origin.send(st.error_reply(stanza, "cancel", "undefined-condition", "msg or err_code not found"));
return true;
diff --git a/storage-backend/index.php b/storage-backend/index.php
index eae06ef..a7c79d3 100644
--- a/storage-backend/index.php
+++ b/storage-backend/index.php
@@ -67,7 +67,7 @@ switch ($method) {
// Check if xmppServerKey is allowed to request slots
if (false === checkXmppServerKey($config['valid_xmpp_server_keys'], $xmppServerKey)) {
- sendHttpReturnCodeAndJson(403, 'Server is not allowed to request an upload slot');
+ sendHttpReturnCodeAndJson(403, 'Server is not allowed to request an '.$slotType.' slot');
}
switch ($slotType) {