# HG changeset patch # User Kim Alvefur # Date 1640803228 -3600 # Node ID f69c5a443156ea3c2c92e2b0386a6dbf499d2fb9 # Parent e9b7c8db3ebd2fe2ae914b8c0a8087d33ed7c774 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. diff -r e9b7c8db3ebd -r f69c5a443156 mod_rest/jsonmap.lib.lua --- 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); diff -r e9b7c8db3ebd -r f69c5a443156 mod_rest/mod_rest.lua --- 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"); diff -r e9b7c8db3ebd -r f69c5a443156 mod_rest/res/schema-xmpp.json --- 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" } } },