# HG changeset patch # User Kim Alvefur # Date 1651273201 -7200 # Node ID a85efae90e213b12df579d1ed9629850cb4127d8 # Parent ae83200fb55f7f850217bea63b46842d5d008798 mod_rest: Expand mapping of XEP-0045 join stanza The previous 'join' mapping was apparently lost in translation when swithing to datamapper, so might as well map some properties allowing history control. Usually you probably want either zero history or history since the last known time of being joined. Maybe that the former should be the default? diff -r ae83200fb55f -r a85efae90e21 mod_rest/README.markdown --- a/mod_rest/README.markdown Tue Apr 26 22:42:09 2022 +0200 +++ b/mod_rest/README.markdown Sat Apr 30 01:00:01 2022 +0200 @@ -276,9 +276,6 @@ `status` : Human-readable status message. -`join` -: Boolean. Join a group chat. - #### Info-Queries Only one type of payload can be included in an `iq`. @@ -435,8 +432,8 @@ ### Presence -`join` -: Boolean, used to join group chats. +`muc` +: Object with [MUC][XEP-0045] related properties. ### IQ diff -r ae83200fb55f -r a85efae90e21 mod_rest/jsonmap.lib.lua --- a/mod_rest/jsonmap.lib.lua Tue Apr 26 22:42:09 2022 +0200 +++ b/mod_rest/jsonmap.lib.lua Sat Apr 30 01:00:01 2022 +0200 @@ -538,6 +538,11 @@ t.payload.data = json.encode(t.payload.data); end + if kind == "presence" and t.join == true and t.muc == nil then + -- COMPAT Older boolean 'join' property used with XEP-0045 + t.muc = {}; + end + local s = map.unparse(schema, { [kind or "message"] = t }).tags[1]; s.attr.type = t_type; diff -r ae83200fb55f -r a85efae90e21 mod_rest/res/openapi.yaml --- a/mod_rest/res/openapi.yaml Tue Apr 26 22:42:09 2022 +0200 +++ b/mod_rest/res/openapi.yaml Sat Apr 30 01:00:01 2022 +0200 @@ -283,8 +283,8 @@ idle_since: $ref: '#/components/schemas/idle_since' - join: - $ref: '#/components/schemas/join' + muc: + $ref: '#/components/schemas/muc' error: $ref: '#/components/schemas/error' @@ -510,11 +510,37 @@ namespace: urn:xmpp:message-correct:0 x_single_attribute: id - join: - description: For joining Multi-User-Chats - type: boolean - enum: - - true + muc: + description: Multi-User-Chat related + type: object + xml: + name: x + namespace: http://jabber.org/protocol/muc + properties: + history: + type: object + properties: + maxchars: + type: integer + minimum: 0 + xml: + attribute: true + maxstanzas: + type: integer + minimum: 0 + xml: + attribute: true + seconds: + type: integer + minimum: 0 + xml: + attribute: true + since: + type: string + format: date-time + xml: + attribute: true + invite: type: object diff -r ae83200fb55f -r a85efae90e21 mod_rest/res/schema-xmpp.json --- a/mod_rest/res/schema-xmpp.json Tue Apr 26 22:42:09 2022 +0200 +++ b/mod_rest/res/schema-xmpp.json Sat Apr 30 01:00:01 2022 +0200 @@ -1078,6 +1078,48 @@ "lang" : { "$ref" : "#/_common/lang" }, + "muc" : { + "properties" : { + "history" : { + "properties" : { + "maxchars" : { + "minimum" : 0, + "type" : "integer", + "xml" : { + "attribute" : true + } + }, + "maxstanzas" : { + "minimum" : 0, + "type" : "integer", + "xml" : { + "attribute" : true + } + }, + "seconds" : { + "minimum" : 0, + "type" : "integer", + "xml" : { + "attribute" : true + } + }, + "since" : { + "format" : "date-time", + "type" : "string", + "xml" : { + "attribute" : true + } + } + }, + "type" : "object" + } + }, + "type" : "object", + "xml" : { + "name" : "x", + "namespace" : "http://jabber.org/protocol/muc" + } + }, "nick" : { "$ref" : "#/_common/nick" },