diff 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
line wrap: on
line diff
--- a/src/plugins/plugin_xep_0060.py	Wed Mar 09 16:59:29 2016 +0100
+++ b/src/plugins/plugin_xep_0060.py	Thu Mar 10 17:50:17 2016 +0100
@@ -329,9 +329,10 @@
 
         def addMetadata(result):
             items, rsm_response = result
-            metadata = {'service': service or client.jid.host,
+            service_jid = service if service else jid.JID(client.jid.host)
+            metadata = {'service': service_jid,
                         'node': node,
-                        'uri': self.getNodeURI(service, node),
+                        'uri': self.getNodeURI(service_jid, node),
                        }
             if rsm_request is not None and rsm_response is not None:
                 metadata.update({'rsm_{}'.format(key): value for key, value in rsm_response.toDict().iteritems()})
@@ -409,10 +410,11 @@
     def getNodeURI(self, service, node, item=None):
         """Return XMPP URI of a PubSub node
 
-        @param service(jid.JID, None): PubSub service,
+        @param service(jid.JID): PubSub service,
         @param node(unicode): node
         @return (unicode): URI of the node
         """
+        assert service is not None
         # XXX: urllib.urlencode use "&" to separate value, while XMPP URL (cf. RFC 5122)
         #      use ";" as a separator. So if more than one value is used in query_data,
         #      urlencode MUST NOT BE USED.