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.
This commit is contained in:
Goffi 2020-07-16 09:07:20 +02:00
commit e03eb5bfcc

View file

@ -77,8 +77,8 @@ class XEP_0059(object):
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 @@ class XEP_0059(object):
- 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 @@ class XEP_0059(object):
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