Mercurial > libervia-backend
comparison sat/plugins/plugin_xep_0277.py @ 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 | 6132d363f0e9 |
comparison
equal
deleted
inserted
replaced
3492:fa796612adad | 3493:b54bdd4ec507 |
---|---|
418 publisher = item_elt.getAttribute("publisher") | 418 publisher = item_elt.getAttribute("publisher") |
419 try: | 419 try: |
420 author_elt = next(entry_elt.elements(NS_ATOM, "author")) | 420 author_elt = next(entry_elt.elements(NS_ATOM, "author")) |
421 except StopIteration: | 421 except StopIteration: |
422 log.debug("Can't find author element in item {}".format(id_)) | 422 log.debug("Can't find author element in item {}".format(id_)) |
423 if publisher: | |
424 microblog_data["author_jid"] = publisher | |
425 microblog_data["author_jid_verified"] = True | |
426 else: | |
427 iq_elt = xml_tools.findAncestor(item_elt, "iq", C.NS_CLIENT) | |
428 microblog_data["author_jid"] = iq_elt["from"] | |
429 microblog_data["author_jid_verified"] = False | |
430 else: | 423 else: |
431 # name | 424 # name |
432 try: | 425 try: |
433 name_elt = next(author_elt.elements(NS_ATOM, "name")) | 426 name_elt = next(author_elt.elements(NS_ATOM, "name")) |
434 except StopIteration: | 427 except StopIteration: |
474 email_elt = next(author_elt.elements(NS_ATOM, "email")) | 467 email_elt = next(author_elt.elements(NS_ATOM, "email")) |
475 except StopIteration: | 468 except StopIteration: |
476 pass | 469 pass |
477 else: | 470 else: |
478 microblog_data["author_email"] = str(email_elt) | 471 microblog_data["author_email"] = str(email_elt) |
472 | |
473 if not microblog_data.get("author_jid"): | |
474 if publisher: | |
475 microblog_data["author_jid"] = publisher | |
476 microblog_data["author_jid_verified"] = True | |
477 else: | |
478 iq_elt = xml_tools.findAncestor(item_elt, "iq", C.NS_CLIENT) | |
479 microblog_data["author_jid"] = iq_elt["from"] | |
480 microblog_data["author_jid_verified"] = False | |
479 | 481 |
480 # categories | 482 # categories |
481 categories = [ | 483 categories = [ |
482 category_elt.getAttribute("term", "") | 484 category_elt.getAttribute("term", "") |
483 for category_elt in entry_elt.elements(NS_ATOM, "category") | 485 for category_elt in entry_elt.elements(NS_ATOM, "category") |