Software /
code /
prosody-modules
Diff
mod_rest/jsonmap.lib.lua @ 5119:048e339706ba
mod_rest: Remove manual reference expansion in schema
This hack was originally added to reduce the number of definitions of
common attributes (type, to, from etc) and payloads (e.g. delay). This
predated pointers and references, and until now was needed because
parsing picked out the correct stanza kind from the schema, which broke
internal references.
Removing this hack paves the way for allowing the schema to be
configured or customized more easily.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 20 Dec 2022 21:48:28 +0100 |
parent | 4947:b171ddf1bc3e |
line wrap: on
line diff
--- a/mod_rest/jsonmap.lib.lua Sun Dec 18 15:30:02 2022 +0100 +++ b/mod_rest/jsonmap.lib.lua Tue Dec 20 21:48:28 2022 +0100 @@ -16,13 +16,6 @@ copyto.properties[key] = prop; end 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 = 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; - schema._common = nil; end end @@ -406,9 +399,21 @@ end return { xmpp = result }; end - local t = map.parse(schema.properties[s.name], s); - t.kind = s.name; + local t; + do + local wrap_s = st.stanza("xmpp", { xmlns = "jabber:client" }):add_child(s); + local wrap_t = map.parse(schema, wrap_s); + if not wrap_t then + return nil, "parse"; + end + local kind; + kind, t = next(wrap_t); + if kind == nil then + return nil, "parse"; + end + t.kind = kind; + end if s.name == "presence" and not s.attr.type then t.type = "available";