fix: JSON parsing in decryptRoomEvent method
This makes the use of the event content null safe and type safe which fixes a regression when sessionId is null.
This commit is contained in:
parent
872b3bff94
commit
048b7faba0
|
|
@ -285,21 +285,34 @@ class Encryption {
|
||||||
if (event.type != EventTypes.Encrypted) {
|
if (event.type != EventTypes.Encrypted) {
|
||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
final content = event.parsedRoomEncryptedContent;
|
||||||
|
final sessionId = content.sessionId;
|
||||||
try {
|
try {
|
||||||
if (client.database != null &&
|
if (client.database != null &&
|
||||||
|
sessionId != null &&
|
||||||
!(keyManager
|
!(keyManager
|
||||||
.getInboundGroupSession(roomId, event.content['session_id'],
|
.getInboundGroupSession(
|
||||||
event.content['sender_key'])
|
roomId,
|
||||||
|
sessionId,
|
||||||
|
content.senderKey,
|
||||||
|
)
|
||||||
?.isValid ??
|
?.isValid ??
|
||||||
false)) {
|
false)) {
|
||||||
await keyManager.loadInboundGroupSession(
|
await keyManager.loadInboundGroupSession(
|
||||||
roomId, event.content['session_id'], event.content['sender_key']);
|
roomId,
|
||||||
|
sessionId,
|
||||||
|
content.senderKey,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
event = decryptRoomEventSync(roomId, event);
|
event = decryptRoomEventSync(roomId, event);
|
||||||
if (event.type == EventTypes.Encrypted &&
|
if (event.type == EventTypes.Encrypted &&
|
||||||
event.content['can_request_session'] == true) {
|
event.content['can_request_session'] == true &&
|
||||||
|
sessionId != null) {
|
||||||
keyManager.maybeAutoRequest(
|
keyManager.maybeAutoRequest(
|
||||||
roomId, event.content['session_id'], event.content['sender_key']);
|
roomId,
|
||||||
|
sessionId,
|
||||||
|
content.senderKey,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if (event.type != EventTypes.Encrypted && store) {
|
if (event.type != EventTypes.Encrypted && store) {
|
||||||
if (updateType != EventUpdateType.history) {
|
if (updateType != EventUpdateType.history) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue