Merge branch 'client-fix-logs' into 'master'
[Client] Dont create new inbound session when session matches See merge request famedly/famedlysdk!214
This commit is contained in:
commit
5a4c484db6
|
@ -1025,7 +1025,10 @@ class Client {
|
|||
try {
|
||||
toDeviceEvent = decryptToDeviceEvent(toDeviceEvent);
|
||||
} catch (e) {
|
||||
print("[LibOlm] Could not decrypt to device event: " + e.toString());
|
||||
print(
|
||||
"[LibOlm] Could not decrypt to device event from ${toDeviceEvent.sender}: " +
|
||||
e.toString());
|
||||
print(toDeviceEvent.sender);
|
||||
toDeviceEvent = ToDeviceEvent.fromJson(events[i]);
|
||||
}
|
||||
}
|
||||
|
@ -1320,8 +1323,10 @@ class Client {
|
|||
Room room = getRoomById(toDeviceEvent.content["room_id"]);
|
||||
if (room != null && toDeviceEvent.content["session_id"] is String) {
|
||||
final String sessionId = toDeviceEvent.content["session_id"];
|
||||
if (room != null) {
|
||||
room.setSessionKey(sessionId, toDeviceEvent.content);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
} catch (e) {
|
||||
|
@ -1570,7 +1575,11 @@ class Client {
|
|||
List<olm.Session> existingSessions = olmSessions[senderKey];
|
||||
if (existingSessions != null) {
|
||||
for (olm.Session session in existingSessions) {
|
||||
if ((type == 0 && session.matches_inbound(body) == 1) || type == 1) {
|
||||
if (type == 0 && session.matches_inbound(body) != 0) {
|
||||
plaintext = session.decrypt(type, body);
|
||||
storeOlmSession(senderKey, session);
|
||||
break;
|
||||
} else if (type == 1) {
|
||||
try {
|
||||
plaintext = session.decrypt(type, body);
|
||||
storeOlmSession(senderKey, session);
|
||||
|
@ -1679,6 +1688,7 @@ class Client {
|
|||
};
|
||||
final olm.EncryptResult encryptResult =
|
||||
existingSessions.first.encrypt(json.encode(payload));
|
||||
storeOlmSession(device.curve25519Key, existingSessions.first);
|
||||
encryptedMessage["ciphertext"][device.curve25519Key] = {
|
||||
"type": encryptResult.type,
|
||||
"body": encryptResult.body,
|
||||
|
|
|
@ -836,7 +836,7 @@ class Room {
|
|||
.getItem("/clients/${client.deviceID}/rooms/${this.id}/session_keys");
|
||||
if (sessionKeysPickle?.isNotEmpty ?? false) {
|
||||
final Map<String, dynamic> map = json.decode(sessionKeysPickle);
|
||||
this._sessionKeys = {};
|
||||
if (this._sessionKeys == null) this._sessionKeys = {};
|
||||
for (var entry in map.entries) {
|
||||
try {
|
||||
this._sessionKeys[entry.key] =
|
||||
|
@ -848,6 +848,9 @@ class Room {
|
|||
}
|
||||
}
|
||||
}
|
||||
await client.storeAPI?.setItem(
|
||||
"/clients/${client.deviceID}/rooms/${this.id}/session_keys",
|
||||
json.encode(sessionKeys));
|
||||
_fullyRestored = true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue