Mercurial > libervia-backend
comparison 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 |
comparison
equal
deleted
inserted
replaced
4362:d34b17bce612 | 4363:4da560a8aed3 |
---|---|
1331 "parse_message used with a non <message/> stanza, ignoring: {xml}".format( | 1331 "parse_message used with a non <message/> stanza, ignoring: {xml}".format( |
1332 xml=message_elt.toXml() | 1332 xml=message_elt.toXml() |
1333 ) | 1333 ) |
1334 ) | 1334 ) |
1335 ) | 1335 ) |
1336 return {} | 1336 return MessageData() |
1337 | 1337 |
1338 if message_elt.uri == None: | 1338 if message_elt.uri == None: |
1339 # xmlns may be None when wokkel element parsing strip out root namespace | 1339 # xmlns may be None when wokkel element parsing strip out root namespace |
1340 self.normalize_ns(message_elt, None) | 1340 self.normalize_ns(message_elt, None) |
1341 elif message_elt.uri != C.NS_CLIENT: | 1341 elif message_elt.uri != C.NS_CLIENT: |
1353 message_elt["to"] = client.jid.full() | 1353 message_elt["to"] = client.jid.full() |
1354 | 1354 |
1355 message = {} | 1355 message = {} |
1356 subject = {} | 1356 subject = {} |
1357 extra = {} | 1357 extra = {} |
1358 data: MessageData = { | 1358 data = MessageData({ |
1359 "from": jid.JID(message_elt["from"]), | 1359 "from": jid.JID(message_elt["from"]), |
1360 "to": jid.JID(message_elt["to"]), | 1360 "to": jid.JID(message_elt["to"]), |
1361 "uid": message_elt.getAttribute( | 1361 "uid": message_elt.getAttribute( |
1362 "uid", str(uuid.uuid4()) | 1362 "uid", str(uuid.uuid4()) |
1363 ), # XXX: uid is not a standard attribute but may be added by plugins | 1363 ), # XXX: uid is not a standard attribute but may be added by plugins |
1364 "message": message, | 1364 "message": message, |
1365 "subject": subject, | 1365 "subject": subject, |
1366 "type": message_elt.getAttribute("type", "normal"), | 1366 "type": message_elt.getAttribute("type", "normal"), |
1367 "extra": extra, | 1367 "extra": extra, |
1368 } | 1368 }) |
1369 | 1369 |
1370 try: | 1370 try: |
1371 message_id = data["extra"]["message_id"] = message_elt["id"] | 1371 message_id = extra["message_id"] = message_elt["id"] |
1372 except KeyError: | 1372 except KeyError: |
1373 pass | 1373 pass |
1374 else: | 1374 else: |
1375 client.mess_id2uid[(data["from"], message_id)] = data["uid"] | 1375 client.mess_id2uid[(data["from"], message_id)] = data["uid"] |
1376 | 1376 |
1379 message[e.getAttribute((C.NS_XML, "lang"), "")] = str(e) | 1379 message[e.getAttribute((C.NS_XML, "lang"), "")] = str(e) |
1380 | 1380 |
1381 # subject | 1381 # subject |
1382 for e in message_elt.elements(C.NS_CLIENT, "subject"): | 1382 for e in message_elt.elements(C.NS_CLIENT, "subject"): |
1383 subject[e.getAttribute((C.NS_XML, "lang"), "")] = str(e) | 1383 subject[e.getAttribute((C.NS_XML, "lang"), "")] = str(e) |
1384 | |
1385 # thread | |
1386 for e in message_elt.elements(C.NS_CLIENT, "thread"): | |
1387 extra["thread"] = str(e) | |
1388 if e.hasAttribute("parent"): | |
1389 extra["thread_parent"] = e["parent"] | |
1390 # Per RFC, we can't have more than one <thread>. | |
1391 break | |
1384 | 1392 |
1385 # delay and timestamp | 1393 # delay and timestamp |
1386 try: | 1394 try: |
1387 received_timestamp = message_elt._received_timestamp | 1395 received_timestamp = message_elt._received_timestamp |
1388 except AttributeError: | 1396 except AttributeError: |