diff sat/plugins/plugin_xep_0184.py @ 3129:95befc85e816

plugin XEP-0184: show a warning and the message XML on missing `id`
author Goffi <goffi@goffi.org>
date Mon, 27 Jan 2020 19:53:31 +0100
parents ab2696e34d29
children 559a625a236b
line wrap: on
line diff
--- a/sat/plugins/plugin_xep_0184.py	Mon Jan 27 19:52:49 2020 +0100
+++ b/sat/plugins/plugin_xep_0184.py	Mon Jan 27 19:53:31 2020 +0100
@@ -152,7 +152,11 @@
 
         if self._isActif(client.profile) and client.roster.isPresenceAuthorised(from_jid):
             received_elt_ret = domish.Element((NS_MESSAGE_DELIVERY_RECEIPTS, "received"))
-            received_elt_ret["id"] = msg_elt["id"]
+            try:
+                received_elt_ret["id"] = msg_elt["id"]
+            except KeyError:
+                log.warning(f"missing id for message element: {msg_elt.toXml}")
+                return
 
             msg_result_elt = xmlstream.toResponse(msg_elt, "result")
             msg_result_elt.addChild(received_elt_ret)