diff sat/plugins/plugin_xep_0374.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 80d29f55ba8b
children f461f11ea176
line wrap: on
line diff
--- a/sat/plugins/plugin_xep_0374.py	Sat Oct 15 20:38:33 2022 +0200
+++ b/sat/plugins/plugin_xep_0374.py	Sat Oct 15 20:38:33 2022 +0200
@@ -209,7 +209,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