changeset 3069:73db9db8b9e1

plugin XEP-0277: fixed comments URLs parsing
author Goffi <goffi@goffi.org>
date Fri, 08 Nov 2019 11:55:21 +0100
parents e189ceca7e8b
children 1370323e8f6c
files sat/plugins/plugin_xep_0060.py sat/plugins/plugin_xep_0277.py
diffstat 2 files changed, 5 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/sat/plugins/plugin_xep_0060.py	Fri Nov 08 11:47:42 2019 +0100
+++ b/sat/plugins/plugin_xep_0060.py	Fri Nov 08 11:55:21 2019 +0100
@@ -1128,10 +1128,8 @@
         """
         items, metadata = items_data
 
-        def eb(failure):
-            log.warning(
-                "Error while serialising/parsing item: {}".format(str(failure.value))
-            )
+        def eb(failure_):
+            log.warning(f"Error while serialising/parsing item: {failure_.value}")
 
         d = defer.gatherResults([item_cb(item).addErrback(eb) for item in items])
 
--- a/sat/plugins/plugin_xep_0277.py	Fri Nov 08 11:47:42 2019 +0100
+++ b/sat/plugins/plugin_xep_0277.py	Fri Nov 08 11:55:21 2019 +0100
@@ -365,8 +365,8 @@
                 microblog_data[key] = link_elt["href"]
                 try:
                     service, node = self.parseCommentUrl(microblog_data[key])
-                except:
-                    log.warning("Can't parse url {}".format(microblog_data[key]))
+                except Exception as e:
+                    log.warning(f"Can't parse url {microblog_data[key]}: {e}")
                     del microblog_data[key]
                 else:
                     microblog_data["{}_service".format(key)] = service.full()
@@ -853,7 +853,7 @@
         """
         parsed_url = urllib.parse.urlparse(node_url, "xmpp")
         service = jid.JID(parsed_url.path)
-        parsed_queries = urllib.parse.parse_qs(parsed_url.query.encode("utf-8"))
+        parsed_queries = urllib.parse.parse_qs(parsed_url.query)
         node = parsed_queries.get("node", [""])[0]
 
         if not node: