Mercurial > prosody-modules
changeset 4841:f69c5a443156
mod_rest: Fix nested message stanzas in XEP-0297 containers
It's all a bit awkward because it doesn't normally use the whole schema
directly, but rather checks which stanza type is used and picks out that
property as a schema. Which also prevents references from working.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 29 Dec 2021 19:40:28 +0100 |
parents | e9b7c8db3ebd |
children | 8d4b91a703af |
files | mod_rest/jsonmap.lib.lua mod_rest/mod_rest.lua mod_rest/res/schema-xmpp.json |
diffstat | 3 files changed, 10 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/mod_rest/jsonmap.lib.lua Wed Dec 29 18:31:40 2021 +0100 +++ b/mod_rest/jsonmap.lib.lua Wed Dec 29 19:40:28 2021 +0100 @@ -18,7 +18,7 @@ end schema.properties.message.properties.archive.properties.forward = schema.properties.message.properties.forwarded; schema.properties.message.properties.forwarded.properties.delay = schema._common.delay; - schema.properties.message.properties.forwarded.properties.message.properties = schema.properties.message.properties; + schema.properties.message.properties.forwarded.properties.message = schema.properties.message; schema.properties.iq.properties.archive.properties.form = schema._common.dataform; schema.properties.iq.properties.archive.properties.page = schema._common.rsm; schema.properties.iq.properties.result.properties.page = schema._common.rsm; @@ -536,7 +536,7 @@ end end - local s = map.unparse(schema.properties[kind or "message"], t); + local s = map.unparse(schema, { [kind or "message"] = t }).tags[1]; s.attr.type = t_type; s.attr.to = str(t.to) and jid.prep(t.to);
--- a/mod_rest/mod_rest.lua Wed Dec 29 18:31:40 2021 +0100 +++ b/mod_rest/mod_rest.lua Wed Dec 29 19:40:28 2021 +0100 @@ -297,7 +297,7 @@ return post_errors.new("parse", ctx); end - if payload.attr.xmlns then + if (payload.attr.xmlns or "jabber:client") ~= "jabber:client" then return post_errors.new("xmlns"); elseif payload.name ~= "message" and payload.name ~= "presence" and payload.name ~= "iq" then return post_errors.new("name");
--- a/mod_rest/res/schema-xmpp.json Wed Dec 29 18:31:40 2021 +0100 +++ b/mod_rest/res/schema-xmpp.json Wed Dec 29 19:40:28 2021 +0100 @@ -565,7 +565,8 @@ }, "type" : "object", "xml" : { - "name" : "iq" + "name" : "iq", + "namespace" : "jabber:client" } }, "message" : { @@ -631,7 +632,7 @@ "$ref" : "#/_common/delay" }, "message" : { - "$ref" : "#/message" + "$ref" : "#/properties/message" } }, "title" : "XEP-0297: Stanza Forwarding", @@ -894,7 +895,8 @@ }, "type" : "object", "xml" : { - "name" : "message" + "name" : "message", + "namespace" : "jabber:client" } }, "presence" : { @@ -1006,7 +1008,8 @@ }, "type" : "object", "xml" : { - "name" : "presence" + "name" : "presence", + "namespace" : "jabber:client" } } },