Mercurial > libervia-backend
changeset 2717:e3f6de6ce320
plugin XEP-0059: added serialise method
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 10 Dec 2018 20:34:45 +0100 |
parents | 06160b529da6 |
children | bb6adaa580ee |
files | sat/plugins/plugin_xep_0059.py |
diffstat | 1 files changed, 27 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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)