plugin XEP-0308: check message edit for room messages:
- Reference the stanza-id assigned by the MUC service when correcting. - Ignore the edit (with a warning) if the original message has no usable id.
This commit is contained in:
parent
403b9e9d31
commit
7a7a3d8fe4
1 changed files with 13 additions and 1 deletions
|
|
@ -293,6 +293,18 @@ class XEP_0308:
|
|||
store=not is_group_chat,
|
||||
)
|
||||
|
||||
ref_id = edited_history.stanza_id if is_group_chat else edited_history.origin_id
|
||||
if not ref_id:
|
||||
orig_data = edited_history.serialise()
|
||||
orig_data["from"] = jid.JID(orig_data["from"])
|
||||
orig_data["to"] = jid.JID(orig_data["to"])
|
||||
log.warning(
|
||||
f"Can't correct message {message_id}: the original message has no usable "
|
||||
f"id (stanza_id={edited_history.stanza_id}, "
|
||||
f"origin_id={edited_history.origin_id}), ignoring the edit."
|
||||
)
|
||||
return
|
||||
|
||||
serialised = edited_history.serialise()
|
||||
serialised["uid"] = str(uuid.uuid4())
|
||||
serialised["from"] = client.jid
|
||||
|
|
@ -301,7 +313,7 @@ class XEP_0308:
|
|||
|
||||
message_elt = client.generate_message_xml(serialised)["xml"]
|
||||
replace_elt = message_elt.addElement((NS_MESSAGE_CORRECT, "replace"))
|
||||
replace_elt["id"] = edited_history.origin_id
|
||||
replace_elt["id"] = ref_id
|
||||
self._h.add_hint_elements(message_elt, [self._h.HINT_STORE])
|
||||
client.send(message_elt)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue