refactor: Added type casts for refactored dart_openapi_codegen

This commit is contained in:
Malin Errenst 2023-06-07 17:38:29 +02:00
parent ec84af679e
commit 17df38b874
No known key found for this signature in database
2 changed files with 34 additions and 30 deletions

View File

@ -640,8 +640,10 @@ class KeyManager {
final sessionData = session.sessionData; final sessionData = session.sessionData;
Map<String, dynamic>? decrypted; Map<String, dynamic>? decrypted;
try { try {
decrypted = json.decode(decryption.decrypt(sessionData['ephemeral'], decrypted = json.decode(decryption.decrypt(
sessionData['mac'], sessionData['ciphertext'])); sessionData['ephemeral'] as String,
sessionData['mac'] as String,
sessionData['ciphertext'] as String));
} catch (e, s) { } catch (e, s) {
Logs().e('[LibOlm] Error decrypting room key', e, s); Logs().e('[LibOlm] Error decrypting room key', e, s);
} }

View File

@ -597,34 +597,36 @@ class OlmManager {
client.userDeviceKeys[userId]!.deviceKeys[deviceId]!.ed25519Key; client.userDeviceKeys[userId]!.deviceKeys[deviceId]!.ed25519Key;
final identityKey = final identityKey =
client.userDeviceKeys[userId]!.deviceKeys[deviceId]!.curve25519Key; client.userDeviceKeys[userId]!.deviceKeys[deviceId]!.curve25519Key;
for (final Map<String, dynamic> deviceKey for (final deviceKey in deviceKeysEntry.value.values) {
in deviceKeysEntry.value.values) { if (deviceKey is Map<String, Object?>) {
if (fingerprintKey == null || if (fingerprintKey == null ||
identityKey == null || identityKey == null ||
!deviceKey.checkJsonSignature(fingerprintKey, userId, deviceId)) { !deviceKey.checkJsonSignature(
Logs().w( fingerprintKey, userId, deviceId)) {
'Skipping invalid device key from $userId:$deviceId', Logs().w(
deviceKey, 'Skipping invalid device key from $userId:$deviceId',
); deviceKey,
continue; );
} continue;
Logs().v('[OlmManager] Starting session with $userId:$deviceId'); }
final session = olm.Session(); Logs().v('[OlmManager] Starting session with $userId:$deviceId');
try { final session = olm.Session();
session.create_outbound( try {
_olmAccount!, identityKey, deviceKey['key']); session.create_outbound(
await storeOlmSession(OlmSession( _olmAccount!, identityKey, deviceKey['key'] as String);
key: client.userID!, await storeOlmSession(OlmSession(
identityKey: identityKey, key: client.userID!,
sessionId: session.session_id(), identityKey: identityKey,
session: session, sessionId: session.session_id(),
lastReceived: session: session,
DateTime.now(), // we want to use a newly created session lastReceived:
)); DateTime.now(), // we want to use a newly created session
} catch (e, s) { ));
session.free(); } catch (e, s) {
Logs() session.free();
.e('[LibOlm] Could not create new outbound olm session', e, s); Logs().e(
'[LibOlm] Could not create new outbound olm session', e, s);
}
} }
} }
} }