# HG changeset patch # User Goffi # Date 1544470485 -3600 # Node ID e3f6de6ce3209654623aaedb0d6487652d948e61 # Parent 06160b529da68b496197cc06add0b05966654d33 plugin XEP-0059: added serialise method diff -r 06160b529da6 -r e3f6de6ce320 sat/plugins/plugin_xep_0059.py --- a/sat/plugins/plugin_xep_0059.py Sun Dec 09 14:07:26 2018 +0100 +++ b/sat/plugins/plugin_xep_0059.py Mon Dec 10 20:34:45 2018 +0100 @@ -74,6 +74,33 @@ 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)