Mercurial > libervia-backend
comparison src/plugins/plugin_xep_0060.py @ 1904:614f3abb2c69
plugin XEP-0060: fixed traceback if service was None
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 10 Mar 2016 17:50:17 +0100 |
parents | 29564cec913f |
children | 2daf7b4c6756 |
comparison
equal
deleted
inserted
replaced
1903:29564cec913f | 1904:614f3abb2c69 |
---|---|
327 if subscribe: | 327 if subscribe: |
328 d.addCallback(doSubscribe) | 328 d.addCallback(doSubscribe) |
329 | 329 |
330 def addMetadata(result): | 330 def addMetadata(result): |
331 items, rsm_response = result | 331 items, rsm_response = result |
332 metadata = {'service': service or client.jid.host, | 332 service_jid = service if service else jid.JID(client.jid.host) |
333 metadata = {'service': service_jid, | |
333 'node': node, | 334 'node': node, |
334 'uri': self.getNodeURI(service, node), | 335 'uri': self.getNodeURI(service_jid, node), |
335 } | 336 } |
336 if rsm_request is not None and rsm_response is not None: | 337 if rsm_request is not None and rsm_response is not None: |
337 metadata.update({'rsm_{}'.format(key): value for key, value in rsm_response.toDict().iteritems()}) | 338 metadata.update({'rsm_{}'.format(key): value for key, value in rsm_response.toDict().iteritems()}) |
338 return (items, metadata) | 339 return (items, metadata) |
339 | 340 |
407 ## misc tools ## | 408 ## misc tools ## |
408 | 409 |
409 def getNodeURI(self, service, node, item=None): | 410 def getNodeURI(self, service, node, item=None): |
410 """Return XMPP URI of a PubSub node | 411 """Return XMPP URI of a PubSub node |
411 | 412 |
412 @param service(jid.JID, None): PubSub service, | 413 @param service(jid.JID): PubSub service, |
413 @param node(unicode): node | 414 @param node(unicode): node |
414 @return (unicode): URI of the node | 415 @return (unicode): URI of the node |
415 """ | 416 """ |
417 assert service is not None | |
416 # XXX: urllib.urlencode use "&" to separate value, while XMPP URL (cf. RFC 5122) | 418 # XXX: urllib.urlencode use "&" to separate value, while XMPP URL (cf. RFC 5122) |
417 # use ";" as a separator. So if more than one value is used in query_data, | 419 # use ";" as a separator. So if more than one value is used in query_data, |
418 # urlencode MUST NOT BE USED. | 420 # urlencode MUST NOT BE USED. |
419 query_data = [('node', node.encode('utf-8'))] | 421 query_data = [('node', node.encode('utf-8'))] |
420 if item is not None: | 422 if item is not None: |