changeset 3763:b2ade5ecdbab

plugin XEP-0277: be sure to have `service` set in `item2mbdata` and `node` when provided rel 365
author Goffi <goffi@goffi.org>
date Fri, 13 May 2022 18:50:33 +0200
parents becd7f1aa033
children 125c7043b277
files sat/plugins/plugin_xep_0277.py
diffstat 1 files changed, 9 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/sat/plugins/plugin_xep_0277.py	Fri May 13 18:48:41 2022 +0200
+++ b/sat/plugins/plugin_xep_0277.py	Fri May 13 18:50:33 2022 +0200
@@ -269,7 +269,10 @@
             if None, "uri" won't be set
         @return: microblog data
         """
-        microblog_data = {}
+        if service is None:
+            service = client.jid.userhostJID()
+
+        microblog_data = {"service": service.full()}
 
         def check_conflict(key, increment=False):
             """Check if key is already in microblog data
@@ -343,9 +346,10 @@
         # uri
         # FIXME: node should alway be set in the future, check FIXME in method signature
         if node is not None:
+            microblog_data["node"] = node
             microblog_data['uri'] = xmpp_uri.buildXMPPUri(
                 "pubsub",
-                path=service.full() if service is not None else client.jid.userhost(),
+                path=service.full(),
                 node=node,
                 item=id_,
             )
@@ -445,13 +449,13 @@
                     "uri": uri,
                 }
                 try:
-                    service, node = self.parseCommentUrl(uri)
+                    comment_service, comment_node = self.parseCommentUrl(uri)
                 except Exception as e:
                     log.warning(f"Can't parse comments url: {e}")
                     continue
                 else:
-                    comments_data["service"] = service.full()
-                    comments_data["node"] = node
+                    comments_data["service"] = comment_service.full()
+                    comments_data["node"] = comment_node
                 comments.append(comments_data)
             else:
                 rel = link_elt.getAttribute("rel", "")