diff sat/plugins/plugin_xep_0059.py @ 3308:384283adcce1

plugins XEP-0059, XEP-0060, XEP-0277, XEP-0313: better serialisation: `data_format.serialise` is now used for `mbGet`, and RSM/MAM values are not transtyped to strings anymore. A serialised dict is now used, items are put in the `items` key. Comments handling has been refactored to use a list for the potentially multiple comments nodes. `rsm` data are now in a `rsm` key of the dict, and `mam` data are merged with other metadata.
author Goffi <goffi@goffi.org>
date Thu, 16 Jul 2020 09:07:20 +0200
parents 559a625a236b
children be6d91572633
line wrap: on
line diff
--- a/sat/plugins/plugin_xep_0059.py	Fri Jun 19 15:47:16 2020 +0200
+++ b/sat/plugins/plugin_xep_0059.py	Thu Jul 16 09:07:20 2020 +0200
@@ -77,8 +77,8 @@
         else:
             return None
 
-    def serialise(self, rsm_response, data=None):
-        """Serialise data for RSM
+    def response2dict(self, rsm_response, data=None):
+        """Return a dict with RSM response
 
         Key set in data can be:
             - rsm_first: first item id in the page
@@ -87,7 +87,7 @@
             - rsm_count: total number of items in the full set (may be approximage)
         If a value doesn't exists, it's not set.
         All values are set as strings.
-        @param rsm_response(rsm.RSMResponse): response to serialise
+        @param rsm_response(rsm.RSMResponse): response to parse
         @param data(dict, None): dict to update with rsm_* data.
             If None, a new dict is created
         @return (dict): data dict
@@ -95,13 +95,11 @@
         if data is None:
             data = {}
         if rsm_response.first is not None:
-            data["rsm_first"] = rsm_response.first
+            data["first"] = rsm_response.first
         if rsm_response.last is not None:
-            data["rsm_last"] = rsm_response.last
+            data["last"] = rsm_response.last
         if rsm_response.index is not None:
-            data["rsm_index"] = str(rsm_response.index)
-        if rsm_response.index is not None:
-            data["rsm_index"] = str(rsm_response.index)
+            data["index"] = rsm_response.index
         return data