Mercurial > prosody-modules
changeset 5954:e5b5a74feb91
mod_rest: Workaround lack of number coercion in util.datamapper for HTTP upload
util.datamapper will not coerce a string into an integer like the
XEP-0363 'size' slot, which becomes a problem when using the HTTP GET
method, passing fields as ?query parameters which are always strings.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 19 Aug 2024 20:08:41 +0200 |
parents | eef6cb08f9e7 |
children | 0616a6687d0c |
files | mod_rest/jsonmap.lib.lua |
diffstat | 1 files changed, 6 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mod_rest/jsonmap.lib.lua Mon Aug 19 18:39:22 2024 +0200 +++ b/mod_rest/jsonmap.lib.lua Mon Aug 19 20:08:41 2024 +0200 @@ -550,6 +550,12 @@ t.payload.data = json.encode(t.payload.data); end + if type(t.upload_request) == "table" and type(t.upload_request.size) == "string" then + -- When using GET /rest/upload_request then the arguments from the query are all strings + t.upload_request.size = tonumber(t.upload_request.size); + end + + if kind == "presence" and t.join == true and t.muc == nil then -- COMPAT Older boolean 'join' property used with XEP-0045 t.muc = {};