diff options
-rw-r--r-- | prosody-module/mod_http_upload_external/mod_http_upload_external.lua | 11 | ||||
-rw-r--r-- | storage-backend/index.php | 2 |
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) { |