diff libervia/backend/core/xmpp.py @ 4363:4da560a8aed3

core (xmpp): parse <thread> element: <thread> were generated from message data, but not parsed for incoming messages. rel 457
author Goffi <goffi@goffi.org>
date Tue, 06 May 2025 00:18:30 +0200
parents 676a320415b9
children
line wrap: on
line diff
--- a/libervia/backend/core/xmpp.py	Tue May 06 00:16:15 2025 +0200
+++ b/libervia/backend/core/xmpp.py	Tue May 06 00:18:30 2025 +0200
@@ -1333,7 +1333,7 @@
                     )
                 )
             )
-            return {}
+            return MessageData()
 
         if message_elt.uri == None:
             # xmlns may be None when wokkel element parsing strip out root namespace
@@ -1355,7 +1355,7 @@
         message = {}
         subject = {}
         extra = {}
-        data: MessageData = {
+        data = MessageData({
             "from": jid.JID(message_elt["from"]),
             "to": jid.JID(message_elt["to"]),
             "uid": message_elt.getAttribute(
@@ -1365,10 +1365,10 @@
             "subject": subject,
             "type": message_elt.getAttribute("type", "normal"),
             "extra": extra,
-        }
+        })
 
         try:
-            message_id = data["extra"]["message_id"] = message_elt["id"]
+            message_id = extra["message_id"] = message_elt["id"]
         except KeyError:
             pass
         else:
@@ -1382,6 +1382,14 @@
         for e in message_elt.elements(C.NS_CLIENT, "subject"):
             subject[e.getAttribute((C.NS_XML, "lang"), "")] = str(e)
 
+        # thread
+        for e in message_elt.elements(C.NS_CLIENT, "thread"):
+            extra["thread"] = str(e)
+            if e.hasAttribute("parent"):
+                extra["thread_parent"] = e["parent"]
+            # Per RFC, we can't have more than one <thread>.
+            break
+
         # delay and timestamp
         try:
             received_timestamp = message_elt._received_timestamp