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


Commits:
dd932855 by lovetox at 2022-05-03T00:01:27+02:00
fix: Handle multiple stanza-id elements

- - - - -
f744ed58 by lovetox at 2022-05-03T00:02:35+02:00
3.0.0.dev3

- - - - -


4 changed files:

- nbxmpp/__init__.py
- nbxmpp/modules/message.py
- nbxmpp/structs.py
- setup.cfg


Changes:

=====================================
nbxmpp/__init__.py
=====================================
@@ -4,4 +4,4 @@ from .protocol import *
 
 gi.require_version('Soup', '2.4')
 
-__version__: str = "3.0.0-dev2"
+__version__: str = "3.0.0.dev3"


=====================================
nbxmpp/modules/message.py
=====================================
@@ -61,10 +61,7 @@ class BaseMessage(BaseModule):
         properties.id = stanza.getID()
         properties.self_message = self._parse_self_message(stanza, properties)
 
-        # Stanza ID
-        id_, by = stanza.getStanzaIDAttrs()
-        if id_ is not None and by is not None:
-            properties.stanza_id = StanzaIDData(id=id_, by=by)
+        properties.stanza_ids = self._parse_stanza_ids(stanza)
 
         if properties.type.is_error:
             properties.error = error_factory(stanza)
@@ -107,3 +104,17 @@ class BaseMessage(BaseModule):
         if properties.type.is_groupchat:
             return False
         return stanza.getFrom().bare_match(stanza.getTo())
+
+    def _parse_stanza_ids(self, stanza):
+        stanza_ids = []
+        for stanza_id in stanza.getTags('stanza-id', namespace=Namespace.SID):
+            id_ = stanza_id.getAttr('id')
+            by = stanza_id.getAttr('by')
+            if not id_ or not by:
+                self._log.warning('Missing attributes on stanza-id')
+                self._log.warning(stanza)
+                continue
+
+            stanza_ids.append(StanzaIDData(id=id_, by=by))
+
+        return stanza_ids
\ No newline at end of file


=====================================
nbxmpp/structs.py
=====================================
@@ -945,7 +945,7 @@ class MessageProperties:
     carbon: Optional[CarbonData] = None
     type: MessageType = MessageType.NORMAL
     id: Optional[str] = None
-    stanza_id: Optional[str] = None
+    stanza_ids: list[StanzaIDData] = field(default_factory=list)
     from_: Optional[JID] = None
     to: Optional[JID] = None
     jid: Optional[JID] = None


=====================================
setup.cfg
=====================================
@@ -1,6 +1,6 @@
 [metadata]
 name = nbxmpp
-version = 3.0.0-dev2
+version = 3.0.0.dev3
 description = XMPP Library
 author = Yann Leboulanger, Philipp Hoerist
 author_email = [email protected]



View it on GitLab: 
https://dev.gajim.org/gajim/python-nbxmpp/-/compare/da6244965e125b517421cda45364d82bae984f44...f744ed58271015d82ab61f4521847d27f5557515

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


_______________________________________________
Commits mailing list
[email protected]
https://lists.gajim.org/cgi-bin/listinfo/commits

Reply via email to