mirror of
https://github.com/matrix-org/pantalaimon.git
synced 2025-07-15 19:19:29 -04:00
client: Decrypt to-device events from the client sync stream.
This commit is contained in:
parent
e2497bca38
commit
d38825704d
1 changed files with 13 additions and 0 deletions
|
@ -26,12 +26,14 @@ from nio import (
|
||||||
ClientConfig,
|
ClientConfig,
|
||||||
EncryptionError,
|
EncryptionError,
|
||||||
Event,
|
Event,
|
||||||
|
ToDeviceEvent,
|
||||||
KeysQueryResponse,
|
KeysQueryResponse,
|
||||||
KeyVerificationEvent,
|
KeyVerificationEvent,
|
||||||
KeyVerificationKey,
|
KeyVerificationKey,
|
||||||
KeyVerificationMac,
|
KeyVerificationMac,
|
||||||
KeyVerificationStart,
|
KeyVerificationStart,
|
||||||
LocalProtocolError,
|
LocalProtocolError,
|
||||||
|
OlmEvent,
|
||||||
MegolmEvent,
|
MegolmEvent,
|
||||||
RoomContextError,
|
RoomContextError,
|
||||||
RoomEncryptedMedia,
|
RoomEncryptedMedia,
|
||||||
|
@ -812,6 +814,17 @@ class PanClient(AsyncClient):
|
||||||
Returns the json response with decrypted events.
|
Returns the json response with decrypted events.
|
||||||
"""
|
"""
|
||||||
logger.info("Decrypting sync")
|
logger.info("Decrypting sync")
|
||||||
|
|
||||||
|
for event in body["to_device"]["events"]:
|
||||||
|
if event["type"] != "m.room.encrypted":
|
||||||
|
continue
|
||||||
|
event = ToDeviceEvent.parse_encrypted_event(event)
|
||||||
|
|
||||||
|
if not isinstance(event, OlmEvent):
|
||||||
|
continue
|
||||||
|
|
||||||
|
self.olm.handle_to_device_event(event)
|
||||||
|
|
||||||
for room_id, room_dict in body["rooms"]["join"].items():
|
for room_id, room_dict in body["rooms"]["join"].items():
|
||||||
try:
|
try:
|
||||||
if not self.rooms[room_id].encrypted:
|
if not self.rooms[room_id].encrypted:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue