Mercurial > prosody-modules
comparison mod_rest/jsonmap.lib.lua @ 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 | 048e339706ba |
| children |
comparison
equal
deleted
inserted
replaced
| 5953:eef6cb08f9e7 | 5954:e5b5a74feb91 |
|---|---|
| 548 | 548 |
| 549 if type(t.payload) == "table" then | 549 if type(t.payload) == "table" then |
| 550 t.payload.data = json.encode(t.payload.data); | 550 t.payload.data = json.encode(t.payload.data); |
| 551 end | 551 end |
| 552 | 552 |
| 553 if type(t.upload_request) == "table" and type(t.upload_request.size) == "string" then | |
| 554 -- When using GET /rest/upload_request then the arguments from the query are all strings | |
| 555 t.upload_request.size = tonumber(t.upload_request.size); | |
| 556 end | |
| 557 | |
| 558 | |
| 553 if kind == "presence" and t.join == true and t.muc == nil then | 559 if kind == "presence" and t.join == true and t.muc == nil then |
| 554 -- COMPAT Older boolean 'join' property used with XEP-0045 | 560 -- COMPAT Older boolean 'join' property used with XEP-0045 |
| 555 t.muc = {}; | 561 t.muc = {}; |
| 556 end | 562 end |
| 557 | 563 |
