changeset 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 e0bfdd379e8d
files frontends/src/jp/cmd_blog.py src/plugins/plugin_xep_0060.py
diffstat 2 files changed, 6 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/frontends/src/jp/cmd_blog.py	Wed Mar 09 16:59:29 2016 +0100
+++ b/frontends/src/jp/cmd_blog.py	Thu Mar 10 17:50:17 2016 +0100
@@ -320,7 +320,7 @@
             try:
                 mb_data = self.host.bridge.mbGet('', '', 1, [], {}, self.profile)[0][0]
             except Exception as e:
-                self.disp(u"Error while retrieving last comment: {}".format(e))
+                self.disp(u"Error while retrieving last item: {}".format(e))
                 self.host.quit(1)
 
             content = mb_data['content_xhtml']
--- 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.