From 436bb119e8c5010b1535fcda0b8559713b9cfaf0 Mon Sep 17 00:00:00 2001 From: Goffi Date: Fri, 13 May 2022 18:50:33 +0200 Subject: [PATCH] plugin XEP-0277: be sure to have `service` set in `item2mbdata` and `node` when provided rel 365 --- sat/plugins/plugin_xep_0277.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/sat/plugins/plugin_xep_0277.py b/sat/plugins/plugin_xep_0277.py index a1b5c11c..fa9f4568 100644 --- a/sat/plugins/plugin_xep_0277.py +++ b/sat/plugins/plugin_xep_0277.py @@ -269,7 +269,10 @@ class XEP_0277(object): 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 @@ class XEP_0277(object): # 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 @@ class XEP_0277(object): "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", "")