plugin XEP-0059: added serialise method

This commit is contained in:
Goffi 2018-12-10 20:34:45 +01:00
commit 97915f0fbe

View file

@ -74,6 +74,33 @@ class XEP_0059(object):
else:
return None
def serialise(self, rsm_response, data=None):
"""Serialise data for RSM
Key set in data can be:
- rsm_first: first item id in the page
- rsm_last: last item id in the page
- rsm_index: position of the first item in the full set (may be approximate)
- 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 data(dict, None): dict to update with rsm_* data.
If None, a new dict is created
@return (dict): data dict
"""
if data is None:
data = {}
if rsm_response.first is not None:
data[u"rsm_first"] = rsm_response.first
if rsm_response.last is not None:
data[u"rsm_last"] = rsm_response.last
if rsm_response.index is not None:
data[u"rsm_index"] = unicode(rsm_response.index)
if rsm_response.index is not None:
data[u"rsm_index"] = unicode(rsm_response.index)
return data
class XEP_0059_handler(xmlstream.XMPPHandler):
implements(iwokkel.IDisco)