Philipp Hörist pushed to branch master at gajim / python-nbxmpp


Commits:
0620ace4 by Philipp Hörist at 2024-04-27T20:53:54+02:00
imprv: Replies: Return JID instead of string

- - - - -


2 changed files:

- nbxmpp/modules/replies.py
- nbxmpp/structs.py


Changes:

=====================================
nbxmpp/modules/replies.py
=====================================
@@ -21,6 +21,7 @@ from typing import TYPE_CHECKING
 
 from nbxmpp.modules.base import BaseModule
 from nbxmpp.namespaces import Namespace
+from nbxmpp.protocol import JID
 from nbxmpp.protocol import Message
 from nbxmpp.structs import MessageProperties
 from nbxmpp.structs import ReplyData
@@ -52,11 +53,17 @@ class Replies(BaseModule):
         if reply is None:
             return
 
-        reply_to = reply.getAttr('to')
-        if reply_to is None:
+        to = reply.getAttr('to')
+        if to is None:
             self._log.warning('Received reply without "to" attribute')
             return
 
+        try:
+            reply_to = JID.from_string(to)
+        except Exception:
+            self._log.warning('Invalid jid on reply element: %s', to)
+            return
+
         reply_to_id = reply.getAttr('id')
         if reply_to_id is None:
             self._log.warning('Received reply without "id"')


=====================================
nbxmpp/structs.py
=====================================
@@ -300,7 +300,7 @@ class CorrectionData(NamedTuple):
 
 
 class ReplyData(NamedTuple):
-    to: str
+    to: JID
     id: str
 
 



View it on GitLab: 
https://dev.gajim.org/gajim/python-nbxmpp/-/commit/0620ace43b3ff2d0af21518ac1319b00de10deeb

-- 
View it on GitLab: 
https://dev.gajim.org/gajim/python-nbxmpp/-/commit/0620ace43b3ff2d0af21518ac1319b00de10deeb
You're receiving this email because of your account on dev.gajim.org.


_______________________________________________
Commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to