diff sat/plugins/plugin_xep_0384.py @ 3944:748094d5a74d

plugin XEP-0374, XEP-0384: handle cases where "to" is not set in <message> for `feedback_jid`
author Goffi <goffi@goffi.org>
date Sat, 15 Oct 2022 20:38:33 +0200
parents 8dc6a4cfda4b
children f461f11ea176
line wrap: on
line diff
--- a/sat/plugins/plugin_xep_0384.py	Sat Oct 15 20:38:33 2022 +0200
+++ b/sat/plugins/plugin_xep_0384.py	Sat Oct 15 20:38:33 2022 +0200
@@ -75,7 +75,6 @@
     "OMEMO"
 ]
 
-
 log = cast(Logger, getLogger(__name__))  # type: ignore[no-untyped-call]
 
 
@@ -1572,7 +1571,10 @@
             if sender_jid.userhostJID() == client.jid.userhostJID():
                 # TODO: I've seen this cause an exception "builtins.KeyError: 'to'", seems
                 # like "to" isn't always set.
-                feedback_jid = jid.JID(message_elt["to"])
+                try:
+                    feedback_jid = jid.JID(message_elt["to"])
+                except KeyError:
+                    feedback_jid = client.server_jid
             else:
                 feedback_jid = sender_jid