Software /
code /
prosody-modules
Changeset
2689:0fc706855af9
mod_http_upload: Keep user- and hostname in locals
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 15 Apr 2017 15:52:54 +0200 |
parents | 2688:ef80c9d0ebff |
children | 2690:43ad92c5b91a |
files | mod_http_upload/mod_http_upload.lua |
diffstat | 1 files changed, 4 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/mod_http_upload/mod_http_upload.lua Sat Apr 15 15:51:29 2017 +0200 +++ b/mod_http_upload/mod_http_upload.lua Sat Apr 15 15:52:54 2017 +0200 @@ -107,6 +107,7 @@ end local function handle_request(origin, stanza, xmlns, filename, filesize, mimetype) + local username, host = origin.username, origin.host; -- local clients only if origin.type ~= "c2s" then module:log("debug", "Request for upload slot from a %s", origin.type); @@ -119,7 +120,7 @@ origin.send(st.error_reply(stanza, "modify", "bad-request", "Invalid filename")); return true; end - expire(origin.username, origin.host); + expire(username, host); if not filesize then module:log("debug", "Missing file size"); origin.send(st.error_reply(stanza, "modify", "bad-request", "Missing or invalid file size")); @@ -130,7 +131,7 @@ :tag("file-too-large", {xmlns=xmlns}) :tag("max-file-size"):text(tostring(file_size_limit))); return true; - elseif not check_quota(origin.username, origin.host, filesize) then + elseif not check_quota(username, host, filesize) then module:log("debug", "Upload of %dB by %s would exceed quota", filesize, origin.full_jid); origin.send(st.error_reply(stanza, "wait", "resource-constraint", "Quota reached")); return true; @@ -159,7 +160,7 @@ until lfs.mkdir(join_path(storage_path, random_dir)) or not lfs.attributes(join_path(storage_path, random_dir, filename)) - datamanager.list_append(origin.username, origin.host, module.name, { + datamanager.list_append(username, host, module.name, { filename = join_path(storage_path, random_dir, filename), size = filesize, time = os.time() }); local slot = random_dir.."/"..filename; pending_slots[slot] = origin.full_jid;