changeset 3493:b54bdd4ec507

plugin XEP-0277: be sure to have an `author_jid` set
author Goffi <goffi@goffi.org>
date Sat, 27 Mar 2021 14:59:50 +0100
parents fa796612adad
children b5bed164dce0
files sat/plugins/plugin_xep_0277.py
diffstat 1 files changed, 9 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/sat/plugins/plugin_xep_0277.py	Sat Mar 27 14:38:27 2021 +0100
+++ b/sat/plugins/plugin_xep_0277.py	Sat Mar 27 14:59:50 2021 +0100
@@ -420,13 +420,6 @@
             author_elt = next(entry_elt.elements(NS_ATOM, "author"))
         except StopIteration:
             log.debug("Can't find author element in item {}".format(id_))
-            if publisher:
-                microblog_data["author_jid"] = publisher
-                microblog_data["author_jid_verified"] = True
-            else:
-                iq_elt = xml_tools.findAncestor(item_elt, "iq", C.NS_CLIENT)
-                microblog_data["author_jid"] = iq_elt["from"]
-                microblog_data["author_jid_verified"] = False
         else:
             # name
             try:
@@ -477,6 +470,15 @@
             else:
                 microblog_data["author_email"] = str(email_elt)
 
+        if not microblog_data.get("author_jid"):
+            if publisher:
+                microblog_data["author_jid"] = publisher
+                microblog_data["author_jid_verified"] = True
+            else:
+                iq_elt = xml_tools.findAncestor(item_elt, "iq", C.NS_CLIENT)
+                microblog_data["author_jid"] = iq_elt["from"]
+                microblog_data["author_jid_verified"] = False
+
         # categories
         categories = [
             category_elt.getAttribute("term", "")