Mercurial > libervia-backend
comparison 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 |
comparison
equal
deleted
inserted
replaced
3943:8dc6a4cfda4b | 3944:748094d5a74d |
---|---|
207 else: | 207 else: |
208 # I'm not sure why this check is required, this code is copied from XEP-0384 | 208 # I'm not sure why this check is required, this code is copied from XEP-0384 |
209 if sender_jid.userhostJID() == client.jid.userhostJID(): | 209 if sender_jid.userhostJID() == client.jid.userhostJID(): |
210 # TODO: I've seen this cause an exception "builtins.KeyError: 'to'", seems | 210 # TODO: I've seen this cause an exception "builtins.KeyError: 'to'", seems |
211 # like "to" isn't always set. | 211 # like "to" isn't always set. |
212 feedback_jid = jid.JID(message_elt["to"]) | 212 try: |
213 feedback_jid = jid.JID(message_elt["to"]) | |
214 except KeyError: | |
215 feedback_jid = client.server_jid | |
213 else: | 216 else: |
214 feedback_jid = sender_jid | 217 feedback_jid = sender_jid |
215 | 218 |
216 sender_bare_jid = sender_jid.userhost() | 219 sender_bare_jid = sender_jid.userhost() |
217 | 220 |