Mercurial > libervia-backend
changeset 1903:29564cec913f
plugin XEP-0060: service, node and uri are added to metadata when doing a getItems
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 09 Mar 2016 16:59:29 +0100 |
parents | 085f29c20f7e |
children | 614f3abb2c69 |
files | src/plugins/plugin_xep_0060.py src/tools/xml_tools.py |
diffstat | 2 files changed, 7 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/plugins/plugin_xep_0060.py Wed Mar 09 14:33:54 2016 +0100 +++ b/src/plugins/plugin_xep_0060.py Wed Mar 09 16:59:29 2016 +0100 @@ -281,6 +281,7 @@ - list of items - metadata with the following keys: - rsm_first, rsm_last, rsm_count, rsm_index: first, last, count and index value of RSMResponse + - service, node: service and node used """ if rsm_request and item_ids: raise ValueError(u"items_id can't be used with rsm") @@ -328,10 +329,12 @@ def addMetadata(result): items, rsm_response = result + metadata = {'service': service or client.jid.host, + 'node': node, + 'uri': self.getNodeURI(service, node), + } if rsm_request is not None and rsm_response is not None: - metadata = {'rsm_{}'.format(key): value for key, value in rsm_response.toDict().iteritems()} - else: - metadata = {} + metadata.update({'rsm_{}'.format(key): value for key, value in rsm_response.toDict().iteritems()}) return (items, metadata) d.addCallback(addMetadata)
--- a/src/tools/xml_tools.py Wed Mar 09 14:33:54 2016 +0100 +++ b/src/tools/xml_tools.py Wed Mar 09 16:59:29 2016 +0100 @@ -39,6 +39,7 @@ html_entity_re = re.compile(r'&([a-zA-Z]+?);') XML_ENTITIES = ('quot', 'amp', 'apos', 'lt', 'gt') +# TODO: move XMLUI stuff in a separate module # Helper functions