Mercurial > libervia-backend
changeset 4156:2729d424dee7
plugin XEP-0359: use same ID as <message> for `origin_id`:
even if the XEP doesn't specify if Message ID must be the same as `origin_id`, using a
different one makes little sense, and is leading to bugs in other implementation (e.g.
Movim using the wrong ID for reactions).
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 22 Nov 2023 15:05:41 +0100 |
parents | 453e53dfc50e |
children | 04cdcb3fd713 |
files | libervia/backend/plugins/plugin_xep_0359.py |
diffstat | 1 files changed, 2 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/libervia/backend/plugins/plugin_xep_0359.py Wed Nov 22 15:00:57 2023 +0100 +++ b/libervia/backend/plugins/plugin_xep_0359.py Wed Nov 22 15:05:41 2023 +0100 @@ -65,7 +65,7 @@ return True def _send_message_data_trigger(self, client, mess_data): - origin_id = mess_data["extra"].get("origin_id") + origin_id = mess_data["extra"].setdefault("origin_id", mess_data.get("uid")) if not origin_id: origin_id = str(uuid.uuid4()) mess_data["extra"]["origin_id"] = origin_id @@ -116,18 +116,15 @@ else: return origin_elt.getAttribute("id") - def add_origin_id(self, element, origin_id=None): + def add_origin_id(self, element: domish.Element, origin_id: str) -> None: """Add a <origin-id/> to a stanza @param element(domish.Element): stanza where the <origin-id/> must be added @param origin_id(str): id to use, None to automatically generate @return (str): origin_id """ - if origin_id is None: - origin_id = str(uuid.uuid4()) sid_elt = element.addElement((NS_SID, "origin-id")) sid_elt["id"] = origin_id - return origin_id def get_handler(self, client): return XEP_0359_handler()