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).
This commit is contained in:
parent
436848048a
commit
9d6158da2b
1 changed files with 2 additions and 5 deletions
|
|
@ -65,7 +65,7 @@ class XEP_0359(object):
|
|||
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 @@ class XEP_0359(object):
|
|||
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()
|
||||
|
|
|
|||
Loading…
Reference in a new issue