fix: Assign correct type to signedOneTimeKeys

This commit is contained in:
Malin Errenst 2023-06-22 17:18:10 +02:00
parent d3f250c69f
commit f310632a83
No known key found for this signature in database
2 changed files with 13 additions and 4 deletions

View File

@ -144,7 +144,7 @@ class OlmManager {
}
_uploadKeysLock = true;
final signedOneTimeKeys = <String, dynamic>{};
final signedOneTimeKeys = <String, Map<String, Object?>>{};
try {
int? uploadedOneTimeKeysCount;
if (oldKeyCount != null) {
@ -287,8 +287,11 @@ class OlmManager {
try {
final String identity =
json.decode(olmAccount.identity_keys())['curve25519'];
session.create_outbound(_olmAccount!, identity, otk['key']);
final key = otk.tryGet<String>('key');
if (key != null) {
session.create_outbound(_olmAccount!, identity, key);
olmAccount.remove_one_time_keys(session);
}
} finally {
session.free();
}

View File

@ -26,6 +26,8 @@ import 'package:http/http.dart';
import 'package:matrix/matrix.dart' as sdk;
import 'package:matrix/matrix.dart';
T? tryCast<T>(dynamic object) => object is T ? object : null;
Map<String, dynamic> decodeJson(dynamic data) {
if (data is String) {
return json.decode(data);
@ -2167,7 +2169,11 @@ class FakeMatrixApi extends BaseClient {
'one_time_key_counts': {
'curve25519': 10,
'signed_curve25519':
decodeJson(req)['one_time_keys']?.keys?.length ?? 0,
tryCast<Map<String, Object?>>(decodeJson(req))
?.tryGetMap<String, Object?>('one_time_keys')
?.keys
.length ??
0,
}
},
'/client/v3/keys/query': (var req) => {