Software /
code /
prosody-modules
Changeset
4242:6a91d217acc9
mod_rest: Add whitespace to improve readability, code navigation
I use {} in vim a lot.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Thu, 12 Nov 2020 20:37:54 +0100 |
parents | 4241:5e8b54deeb30 |
children | 4243:aed7038ab2ab |
files | mod_rest/mod_rest.lua |
diffstat | 1 files changed, 8 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mod_rest/mod_rest.lua Thu Nov 12 20:36:53 2020 +0100 +++ b/mod_rest/mod_rest.lua Thu Nov 12 20:37:54 2020 +0100 @@ -186,15 +186,18 @@ end return errors.new("parse", ctx, post_errors); end + if payload.attr.xmlns then return errors.new("xmlns", nil, post_errors); elseif payload.name ~= "message" and payload.name ~= "presence" and payload.name ~= "iq" then return errors.new("name", nil, post_errors); end + local to = jid.prep(payload.attr.to); if not to then return errors.new("to", nil, post_errors); end + if payload.attr.from then local requested_from = jid.prep(payload.attr.from); if not requested_from then @@ -206,6 +209,7 @@ return errors.new("from_auth", nil, post_errors); end end + payload.attr = { from = from, to = to, @@ -213,17 +217,20 @@ type = payload.attr.type, ["xml:lang"] = payload.attr["xml:lang"], }; + module:log("debug", "Received[rest]: %s", payload:top_tag()); local send_type = decide_type((request.headers.accept or "") ..",".. request.headers.content_type, supported_outputs) if payload.name == "iq" then function origin.send(stanza) module:send(stanza); end + if payload.attr.type ~= "get" and payload.attr.type ~= "set" then return errors.new("iq_type", nil, post_errors); elseif #payload.tags ~= 1 then return errors.new("iq_tags", nil, post_errors); end + return module:send_iq(payload, origin):next( function (result) module:log("debug", "Sending[rest]: %s", result.stanza:top_tag()); @@ -249,6 +256,7 @@ response:send(encode(send_type, stanza)); return true; end + module:send(payload, origin); return 202; end