Changeset

4935:a85efae90e21

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?
author Kim Alvefur <zash@zash.se>
date Sat, 30 Apr 2022 01:00:01 +0200
parents 4934:ae83200fb55f
children 4936:d63657a85fb4
files mod_rest/README.markdown mod_rest/jsonmap.lib.lua mod_rest/res/openapi.yaml mod_rest/res/schema-xmpp.json
diffstat 4 files changed, 82 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- 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
 
--- 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;
--- 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
--- 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"
             },