# HG changeset patch # User Goffi # Date 1623009988 -7200 # Node ID 7df12ffa662002e01347858fd006046f120919a6 # Parent 3fd60beb9b92def83b62b820dcc5d964d10aa1ad plugin XEP-0277: "user" part of author jid is used for author name when later is missing diff -r 3fd60beb9b92 -r 7df12ffa6620 sat/plugins/plugin_xep_0277.py --- a/sat/plugins/plugin_xep_0277.py Sun Jun 06 19:35:19 2021 +0200 +++ b/sat/plugins/plugin_xep_0277.py Sun Jun 06 22:06:28 2021 +0200 @@ -448,7 +448,7 @@ "No name element found in author element of item {}".format(id_) ) else: - microblog_data["author"] = str(name_elt) + author = microblog_data["author"] = str(name_elt).strip() # uri try: uri_elt = next(author_elt.elements(NS_ATOM, "uri")) @@ -467,6 +467,13 @@ microblog_data["author_jid"] = ( item_elt.getAttribute("publisher") or "" ) + if not author and microblog_data["author_jid"]: + # FIXME: temporary workaround for missing author name, would be + # better to use directly JID's identity (to be done from frontends?) + try: + microblog_data["author"] = jid.JID(microblog_data["author_jid"]).user + except Exception as e: + log.warning(f"No author name found, and can't parse author jid: {e}") if not publisher: log.debug("No publisher attribute, we can't verify author jid")