refactor: Changed Map<String, dynamic> to Map<String, Object?>
- contains breaking changes because some type casts will be needed in Matrix SDK
This commit is contained in:
parent
cf984d61f9
commit
06d587e64f
|
|
@ -30,14 +30,14 @@ import 'package:http/testing.dart';
|
|||
|
||||
import 'package:matrix_api_lite/matrix_api_lite.dart';
|
||||
|
||||
Map<String, dynamic> decodeJson(dynamic data) {
|
||||
Map<String, Object?> decodeJson(dynamic data) {
|
||||
if (data is String) {
|
||||
return json.decode(data) as Map<String, dynamic>;
|
||||
return json.decode(data) as Map<String, Object?>;
|
||||
}
|
||||
if (data is Map && data.isEmpty) {
|
||||
return <String, dynamic>{};
|
||||
return <String, Object?>{};
|
||||
}
|
||||
return data as Map<String, dynamic>;
|
||||
return data as Map<String, Object?>;
|
||||
}
|
||||
|
||||
T? tryCast<T>(dynamic object) => object is T ? object : null;
|
||||
|
|
@ -65,13 +65,13 @@ class FakeMatrixApi extends MockClient {
|
|||
final method = request.method;
|
||||
final dynamic data =
|
||||
method == 'GET' ? request.url.queryParameters : request.body;
|
||||
dynamic res = <String, dynamic>{};
|
||||
dynamic res = <String, Object?>{};
|
||||
var statusCode = 200;
|
||||
|
||||
//print('\$method request to $action with Data: $data');
|
||||
|
||||
// Sync requests with timeout
|
||||
if (data is Map<String, dynamic> && data['timeout'] is String) {
|
||||
if (data is Map<String, Object?> && data['timeout'] is String) {
|
||||
await Future<void>.delayed(Duration(seconds: 5));
|
||||
}
|
||||
|
||||
|
|
@ -92,7 +92,7 @@ class FakeMatrixApi extends MockClient {
|
|||
}
|
||||
} else if (method == 'PUT' &&
|
||||
action.contains('/client/v3/sendToDevice/')) {
|
||||
res = <String, dynamic>{};
|
||||
res = <String, Object?>{};
|
||||
} else if (method == 'GET' &&
|
||||
action.contains('/client/v3/rooms/') &&
|
||||
action.contains('/state/m.room.member/')) {
|
||||
|
|
@ -116,7 +116,7 @@ class FakeMatrixApi extends MockClient {
|
|||
return Response.bytes(utf8.encode(json.encode(res)), statusCode);
|
||||
});
|
||||
|
||||
static Map<String, dynamic> messagesResponse = {
|
||||
static Map<String, Object?> messagesResponse = {
|
||||
'start': 't47429-4392820_219380_26003_2265',
|
||||
'end': 't47409-4357353_219380_26003_2265',
|
||||
'chunk': [
|
||||
|
|
@ -172,10 +172,10 @@ class FakeMatrixApi extends MockClient {
|
|||
'unsigned': {'age': 1234}
|
||||
}
|
||||
],
|
||||
'state': <Map<String, dynamic>>[],
|
||||
'state': <Map<String, Object?>>[],
|
||||
};
|
||||
|
||||
static Map<String, dynamic> syncResponse = {
|
||||
static Map<String, Object?> syncResponse = {
|
||||
'next_batch': Random().nextDouble().toString(),
|
||||
'rooms': {
|
||||
'join': {
|
||||
|
|
@ -394,7 +394,7 @@ class FakeMatrixApi extends MockClient {
|
|||
'override': [
|
||||
{
|
||||
'actions': ['dont_notify'],
|
||||
'conditions': <Map<String, dynamic>>[],
|
||||
'conditions': <Map<String, Object?>>[],
|
||||
'default': true,
|
||||
'enabled': false,
|
||||
'rule_id': '.m.rule.master'
|
||||
|
|
@ -428,7 +428,7 @@ class FakeMatrixApi extends MockClient {
|
|||
'rule_id': '!localpart:server.abc'
|
||||
}
|
||||
],
|
||||
'sender': <Map<String, dynamic>>[],
|
||||
'sender': <Map<String, Object?>>[],
|
||||
'underride': [
|
||||
{
|
||||
'actions': [
|
||||
|
|
@ -676,14 +676,14 @@ class FakeMatrixApi extends MockClient {
|
|||
'device_one_time_keys_count': {'curve25519': 10, 'signed_curve25519': 20},
|
||||
};
|
||||
|
||||
static Map<String, dynamic> archiveSyncResponse = {
|
||||
static Map<String, Object?> archiveSyncResponse = {
|
||||
'next_batch': Random().nextDouble().toString(),
|
||||
'presence': {'events': <Map<String, dynamic>>[]},
|
||||
'account_data': {'events': <Map<String, dynamic>>[]},
|
||||
'to_device': {'events': <Map<String, dynamic>>[]},
|
||||
'presence': {'events': <Map<String, Object?>>[]},
|
||||
'account_data': {'events': <Map<String, Object?>>[]},
|
||||
'to_device': {'events': <Map<String, Object?>>[]},
|
||||
'rooms': {
|
||||
'join': <String, dynamic>{},
|
||||
'invite': <String, dynamic>{},
|
||||
'join': <String, Object?>{},
|
||||
'invite': <String, Object?>{},
|
||||
'leave': {
|
||||
'!5345234234:example.com': {
|
||||
'timeline': {
|
||||
|
|
@ -728,7 +728,7 @@ class FakeMatrixApi extends MockClient {
|
|||
},
|
||||
},
|
||||
'!5345234235:example.com': {
|
||||
'timeline': {'events': <Map<String, dynamic>>[]},
|
||||
'timeline': {'events': <Map<String, Object?>>[]},
|
||||
'state': {
|
||||
'events': [
|
||||
{
|
||||
|
|
@ -748,7 +748,7 @@ class FakeMatrixApi extends MockClient {
|
|||
}
|
||||
};
|
||||
|
||||
static Map<String, dynamic> spaceHierarchyResponse = {
|
||||
static Map<String, Object?> spaceHierarchyResponse = {
|
||||
'rooms': [
|
||||
{
|
||||
'room_id': '!gPxZhKUssFZKZcoCKY:neko.dev',
|
||||
|
|
@ -864,7 +864,7 @@ class FakeMatrixApi extends MockClient {
|
|||
'join_rule': 'public',
|
||||
'world_readable': true,
|
||||
'guest_can_join': true,
|
||||
'children_state': <Map<String, dynamic>>[]
|
||||
'children_state': <Map<String, Object?>>[]
|
||||
},
|
||||
{
|
||||
'room_id': '!aZUzMIEZvEwnDquxLf:neko.dev',
|
||||
|
|
@ -877,7 +877,7 @@ class FakeMatrixApi extends MockClient {
|
|||
'join_rule': 'public',
|
||||
'world_readable': true,
|
||||
'guest_can_join': true,
|
||||
'children_state': <Map<String, dynamic>>[]
|
||||
'children_state': <Map<String, Object?>>[]
|
||||
},
|
||||
{
|
||||
'room_id': '!aRzRZBvOAkHMcEjAPS:libera.chat',
|
||||
|
|
@ -889,7 +889,7 @@ class FakeMatrixApi extends MockClient {
|
|||
'join_rule': 'public',
|
||||
'world_readable': false,
|
||||
'guest_can_join': false,
|
||||
'children_state': <Map<String, dynamic>>[]
|
||||
'children_state': <Map<String, Object?>>[]
|
||||
},
|
||||
{
|
||||
'room_id': '!DXsRRxkqqDhDkAyXfL:matrix.org',
|
||||
|
|
@ -902,7 +902,7 @@ class FakeMatrixApi extends MockClient {
|
|||
'join_rule': 'public',
|
||||
'world_readable': false,
|
||||
'guest_can_join': false,
|
||||
'children_state': <Map<String, dynamic>>[]
|
||||
'children_state': <Map<String, Object?>>[]
|
||||
},
|
||||
{
|
||||
'room_id': '!tbCRpmsMiwMBlIThOd:matrix.org',
|
||||
|
|
@ -914,7 +914,7 @@ class FakeMatrixApi extends MockClient {
|
|||
'join_rule': 'public',
|
||||
'world_readable': false,
|
||||
'guest_can_join': false,
|
||||
'children_state': <Map<String, dynamic>>[]
|
||||
'children_state': <Map<String, Object?>>[]
|
||||
},
|
||||
{
|
||||
'room_id': '!LPpmvMsEgDwuSuHSpM:matrix.org',
|
||||
|
|
@ -926,7 +926,7 @@ class FakeMatrixApi extends MockClient {
|
|||
'join_rule': 'public',
|
||||
'world_readable': true,
|
||||
'guest_can_join': true,
|
||||
'children_state': <Map<String, dynamic>>[]
|
||||
'children_state': <Map<String, Object?>>[]
|
||||
},
|
||||
{
|
||||
'room_id': '!prlZxmnmAGuCYHUNSw:neko.dev',
|
||||
|
|
@ -939,7 +939,7 @@ class FakeMatrixApi extends MockClient {
|
|||
'join_rule': 'public',
|
||||
'world_readable': true,
|
||||
'guest_can_join': false,
|
||||
'children_state': <Map<String, dynamic>>[]
|
||||
'children_state': <Map<String, Object?>>[]
|
||||
},
|
||||
{
|
||||
'room_id': '!ooHixUOgoLVUjCSMZC:matrix.org',
|
||||
|
|
@ -951,12 +951,12 @@ class FakeMatrixApi extends MockClient {
|
|||
'join_rule': 'public',
|
||||
'world_readable': true,
|
||||
'guest_can_join': true,
|
||||
'children_state': <Map<String, dynamic>>[]
|
||||
'children_state': <Map<String, Object?>>[]
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
static final Map<String, Map<String, dynamic Function(dynamic)>> api = {
|
||||
static final Map<String, Map<String, Object? Function(dynamic)>> api = {
|
||||
'GET': {
|
||||
'/path/to/auth/error': (var req) => {
|
||||
'errcode': 'M_FORBIDDEN',
|
||||
|
|
@ -983,7 +983,7 @@ class FakeMatrixApi extends MockClient {
|
|||
'tags': {
|
||||
'm.favourite': {'order': 0.1},
|
||||
'u.Work': {'order': 0.7},
|
||||
'u.Customers': <String, dynamic>{},
|
||||
'u.Customers': <String, Object?>{},
|
||||
}
|
||||
},
|
||||
'/client/v3/events?from=1234&timeout=10&room_id=%211234': (var req) => {
|
||||
|
|
@ -1093,7 +1093,7 @@ class FakeMatrixApi extends MockClient {
|
|||
'network_id': 'gitter',
|
||||
'desc': 'Gitter',
|
||||
'icon': 'mxc://example.org/zXyWvUt',
|
||||
'fields': <String, dynamic>{}
|
||||
'fields': <String, Object?>{}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -1611,7 +1611,7 @@ class FakeMatrixApi extends MockClient {
|
|||
'override': [
|
||||
{
|
||||
'actions': ['dont_notify'],
|
||||
'conditions': <Map<String, dynamic>>[],
|
||||
'conditions': <Map<String, Object?>>[],
|
||||
'default': true,
|
||||
'enabled': false,
|
||||
'rule_id': '.m.rule.master'
|
||||
|
|
@ -1630,8 +1630,8 @@ class FakeMatrixApi extends MockClient {
|
|||
'rule_id': '.m.rule.suppress_notices'
|
||||
}
|
||||
],
|
||||
'room': <Map<String, dynamic>>[],
|
||||
'sender': <Map<String, dynamic>>[],
|
||||
'room': <Map<String, Object?>>[],
|
||||
'sender': <Map<String, Object?>>[],
|
||||
'underride': [
|
||||
{
|
||||
'actions': [
|
||||
|
|
@ -1781,7 +1781,7 @@ class FakeMatrixApi extends MockClient {
|
|||
'algorithm': AlgorithmTypes.megolmBackupV1Curve25519AesSha2,
|
||||
'auth_data': {
|
||||
'public_key': 'GXYaxqhNhUK28zUdxOmEsFRguz+PzBsDlTLlF0O0RkM',
|
||||
'signatures': <String, dynamic>{},
|
||||
'signatures': <String, Object?>{},
|
||||
},
|
||||
'count': 0,
|
||||
'etag': '0',
|
||||
|
|
@ -1840,15 +1840,15 @@ class FakeMatrixApi extends MockClient {
|
|||
(var req) => spaceHierarchyResponse,
|
||||
},
|
||||
'POST': {
|
||||
'/client/v3/delete_devices': (var req) => <String, dynamic>{},
|
||||
'/client/v3/account/3pid/add': (var req) => <String, dynamic>{},
|
||||
'/client/v3/account/3pid/bind': (var req) => <String, dynamic>{},
|
||||
'/client/v3/delete_devices': (var req) => <String, Object?>{},
|
||||
'/client/v3/account/3pid/add': (var req) => <String, Object?>{},
|
||||
'/client/v3/account/3pid/bind': (var req) => <String, Object?>{},
|
||||
'/client/v3/account/3pid/delete': (var req) =>
|
||||
{'id_server_unbind_result': 'success'},
|
||||
'/client/v3/account/3pid/unbind': (var req) =>
|
||||
{'id_server_unbind_result': 'success'},
|
||||
'/client/v3/account/password': (var req) => <String, dynamic>{},
|
||||
'/client/v3/rooms/1234/report/1234': (var req) => <String, dynamic>{},
|
||||
'/client/v3/account/password': (var req) => <String, Object?>{},
|
||||
'/client/v3/rooms/1234/report/1234': (var req) => <String, Object?>{},
|
||||
'/client/v3/search': (var req) => {
|
||||
'search_categories': {
|
||||
'room_events': {
|
||||
|
|
@ -1924,9 +1924,9 @@ class FakeMatrixApi extends MockClient {
|
|||
'submit_url': 'https://example.org/path/to/submitToken'
|
||||
},
|
||||
'/client/v3/rooms/!localpart%3Aexample.com/receipt/m.read/%241234%3Aexample.com':
|
||||
(var req) => <String, dynamic>{},
|
||||
(var req) => <String, Object?>{},
|
||||
'/client/v3/rooms/!localpart%3Aexample.com/read_markers': (var req) =>
|
||||
<String, dynamic>{},
|
||||
<String, Object?>{},
|
||||
'/client/v3/user/${Uri.encodeComponent('alice@example.com')}/filter':
|
||||
(var req) => {'filter_id': '1234'},
|
||||
'/client/v3/publicRooms?server=example.com': (var req) => {
|
||||
|
|
@ -1948,11 +1948,11 @@ class FakeMatrixApi extends MockClient {
|
|||
},
|
||||
'/client/v3/keys/claim': (dynamic req) {
|
||||
final request = decodeJson(req)["one_time_keys"];
|
||||
final keys = (request is Map<String, dynamic>)
|
||||
? request["one_time_keys"] as Map<String, dynamic>?
|
||||
final keys = (request is Map<String, Object?>)
|
||||
? request["one_time_keys"] as Map<String, Object?>?
|
||||
: null;
|
||||
return {
|
||||
'failures': <String, dynamic>{},
|
||||
'failures': <String, Object?>{},
|
||||
'one_time_keys': {
|
||||
if (keys?['@alice:example.com'] != null)
|
||||
'@alice:example.com': {
|
||||
|
|
@ -1986,19 +1986,19 @@ class FakeMatrixApi extends MockClient {
|
|||
};
|
||||
},
|
||||
'/client/v3/rooms/!localpart%3Aexample.com/invite': (var req) =>
|
||||
<String, dynamic>{},
|
||||
<String, Object?>{},
|
||||
'/client/v3/rooms/!localpart%3Aexample.com/leave': (var req) =>
|
||||
<String, dynamic>{},
|
||||
<String, Object?>{},
|
||||
'/client/v3/rooms/!localpart%3Aexample.com/forget': (var req) =>
|
||||
<String, dynamic>{},
|
||||
<String, Object?>{},
|
||||
'/client/v3/rooms/!localpart%3Aserver.abc/kick': (var req) =>
|
||||
<String, dynamic>{},
|
||||
<String, Object?>{},
|
||||
'/client/v3/rooms/!localpart%3Aexample.com/kick': (var req) =>
|
||||
<String, dynamic>{},
|
||||
<String, Object?>{},
|
||||
'/client/v3/rooms/!localpart%3Aexample.com/ban': (var req) =>
|
||||
<String, dynamic>{},
|
||||
<String, Object?>{},
|
||||
'/client/v3/rooms/!localpart%3Aexample.com/unban': (var req) =>
|
||||
<String, dynamic>{},
|
||||
<String, Object?>{},
|
||||
'/client/v3/rooms/!localpart%3Aexample.com/join': (var req) =>
|
||||
{'room_id': '!localpart:example.com'},
|
||||
'/client/v3/join/!localpart%3Aexample.com?server_name=example.com&server_name=example.abc':
|
||||
|
|
@ -2006,7 +2006,7 @@ class FakeMatrixApi extends MockClient {
|
|||
'/client/v3/keys/upload': (var req) => {
|
||||
'one_time_key_counts': {
|
||||
'curve25519': 10,
|
||||
'signed_curve25519': tryCast<Map<String, Map<String, dynamic>>>(
|
||||
'signed_curve25519': tryCast<Map<String, Map<String, Object?>>>(
|
||||
decodeJson(req))?['one_time_keys']
|
||||
?.keys
|
||||
.length ??
|
||||
|
|
@ -2014,7 +2014,7 @@ class FakeMatrixApi extends MockClient {
|
|||
}
|
||||
},
|
||||
'/client/v3/keys/query': (var req) => {
|
||||
'failures': <String, dynamic>{},
|
||||
'failures': <String, Object?>{},
|
||||
'device_keys': {
|
||||
'@alice:example.com': {
|
||||
'JLAFKJWSCS': {
|
||||
|
|
@ -2136,7 +2136,7 @@ class FakeMatrixApi extends MockClient {
|
|||
'ed25519:82mAXjsmbTbrE6zyShpR869jnrANO75H8nYY0nDLoJ8':
|
||||
'82mAXjsmbTbrE6zyShpR869jnrANO75H8nYY0nDLoJ8',
|
||||
},
|
||||
'signatures': <String, dynamic>{},
|
||||
'signatures': <String, Object?>{},
|
||||
},
|
||||
'@othertest:fakeServer.notExisting': {
|
||||
'user_id': '@othertest:fakeServer.notExisting',
|
||||
|
|
@ -2144,7 +2144,7 @@ class FakeMatrixApi extends MockClient {
|
|||
'keys': {
|
||||
'ed25519:master': 'master',
|
||||
},
|
||||
'signatures': <String, dynamic>{},
|
||||
'signatures': <String, Object?>{},
|
||||
},
|
||||
},
|
||||
'self_signing_keys': {
|
||||
|
|
@ -2168,7 +2168,7 @@ class FakeMatrixApi extends MockClient {
|
|||
'keys': {
|
||||
'ed25519:self_signing': 'self_signing',
|
||||
},
|
||||
'signatures': <String, dynamic>{},
|
||||
'signatures': <String, Object?>{},
|
||||
},
|
||||
},
|
||||
'user_signing_keys': {
|
||||
|
|
@ -2192,7 +2192,7 @@ class FakeMatrixApi extends MockClient {
|
|||
'keys': {
|
||||
'ed25519:user_signing': 'user_signing',
|
||||
},
|
||||
'signatures': <String, dynamic>{},
|
||||
'signatures': <String, Object?>{},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -2232,64 +2232,64 @@ class FakeMatrixApi extends MockClient {
|
|||
},
|
||||
'/media/v3/upload?filename=file.jpeg': (var req) =>
|
||||
{'content_uri': 'mxc://example.com/AQwafuaFswefuhsfAFAgsw'},
|
||||
'/client/v3/logout': (var reqI) => <String, dynamic>{},
|
||||
'/client/v3/pushers/set': (var reqI) => <String, dynamic>{},
|
||||
'/client/v3/logout': (var reqI) => <String, Object?>{},
|
||||
'/client/v3/pushers/set': (var reqI) => <String, Object?>{},
|
||||
'/client/v3/join/1234': (var reqI) => {'room_id': '1234'},
|
||||
'/client/v3/logout/all': (var reqI) => <String, dynamic>{},
|
||||
'/client/v3/logout/all': (var reqI) => <String, Object?>{},
|
||||
'/client/v3/createRoom': (var reqI) => {
|
||||
'room_id': '!1234:fakeServer.notExisting',
|
||||
},
|
||||
'/client/v3/rooms/!localpart%3Aserver.abc/read_markers': (var reqI) =>
|
||||
<String, dynamic>{},
|
||||
<String, Object?>{},
|
||||
'/client/v3/rooms/!localpart:server.abc/kick': (var reqI) =>
|
||||
<String, dynamic>{},
|
||||
<String, Object?>{},
|
||||
'/client/v3/rooms/!localpart%3Aserver.abc/ban': (var reqI) =>
|
||||
<String, dynamic>{},
|
||||
<String, Object?>{},
|
||||
'/client/v3/rooms/!localpart%3Aserver.abc/unban': (var reqI) =>
|
||||
<String, dynamic>{},
|
||||
<String, Object?>{},
|
||||
'/client/v3/rooms/!localpart%3Aserver.abc/invite': (var reqI) =>
|
||||
<String, dynamic>{},
|
||||
<String, Object?>{},
|
||||
'/client/v3/keys/device_signing/upload': (var reqI) {
|
||||
return <String, dynamic>{};
|
||||
return <String, Object?>{};
|
||||
},
|
||||
'/client/v3/keys/signatures/upload': (var reqI) =>
|
||||
{'failures': <String, dynamic>{}},
|
||||
{'failures': <String, Object?>{}},
|
||||
'/client/v3/room_keys/version': (var reqI) => {'version': '5'},
|
||||
},
|
||||
'PUT': {
|
||||
'/client/v3/user/%40test%3AfakeServer.notExisting/account_data/m.ignored_user_list':
|
||||
(var req) => <String, dynamic>{},
|
||||
(var req) => <String, Object?>{},
|
||||
'/client/v3/presence/${Uri.encodeComponent('@alice:example.com')}/status':
|
||||
(var req) => <String, dynamic>{},
|
||||
(var req) => <String, Object?>{},
|
||||
'/client/v3/pushrules/global/content/nocake/enabled': (var req) =>
|
||||
<String, dynamic>{},
|
||||
<String, Object?>{},
|
||||
'/client/v3/pushrules/global/content/nocake/actions': (var req) =>
|
||||
<String, dynamic>{},
|
||||
<String, Object?>{},
|
||||
'/client/v3/rooms/!localpart%3Aserver.abc/state/m.room.history_visibility':
|
||||
(var req) => <String, dynamic>{},
|
||||
(var req) => <String, Object?>{},
|
||||
'/client/v3/rooms/!localpart%3Aserver.abc/state/m.room.join_rules':
|
||||
(var req) => <String, dynamic>{},
|
||||
(var req) => <String, Object?>{},
|
||||
'/client/v3/rooms/!localpart%3Aserver.abc/state/m.room.guest_access':
|
||||
(var req) => <String, dynamic>{},
|
||||
(var req) => <String, Object?>{},
|
||||
'/client/v3/rooms/!localpart%3Aserver.abc/send/m.call.invite/1234':
|
||||
(var req) => <String, dynamic>{},
|
||||
(var req) => <String, Object?>{},
|
||||
'/client/v3/rooms/!localpart%3Aserver.abc/send/m.call.answer/1234':
|
||||
(var req) => <String, dynamic>{},
|
||||
(var req) => <String, Object?>{},
|
||||
'/client/v3/rooms/!localpart%3Aserver.abc/send/m.call.candidates/1234':
|
||||
(var req) => <String, dynamic>{},
|
||||
(var req) => <String, Object?>{},
|
||||
'/client/v3/rooms/!localpart%3Aserver.abc/send/m.call.hangup/1234':
|
||||
(var req) => <String, dynamic>{},
|
||||
(var req) => <String, Object?>{},
|
||||
'/client/v3/rooms/!1234%3Aexample.com/redact/1143273582443PhrSn%3Aexample.org/1234':
|
||||
(var req) => {'event_id': '1234'},
|
||||
'/client/v3/pushrules/global/room/!localpart%3Aserver.abc': (var req) =>
|
||||
<String, dynamic>{},
|
||||
<String, Object?>{},
|
||||
'/client/v3/pushrules/global/override/.m.rule.master/enabled':
|
||||
(var req) => <String, dynamic>{},
|
||||
(var req) => <String, Object?>{},
|
||||
'/client/v3/pushrules/global/content/nocake?before=1&after=2':
|
||||
(var req) => <String, dynamic>{},
|
||||
'/client/v3/devices/QBUAZIFURK': (var req) => <String, dynamic>{},
|
||||
(var req) => <String, Object?>{},
|
||||
'/client/v3/devices/QBUAZIFURK': (var req) => <String, Object?>{},
|
||||
'/client/v3/directory/room/%23testalias%3Aexample.com': (var reqI) =>
|
||||
<String, dynamic>{},
|
||||
<String, Object?>{},
|
||||
'/client/v3/rooms/!localpart%3Aserver.abc/send/m.room.message/testtxid':
|
||||
(var reqI) => {
|
||||
'event_id': '\$event${FakeMatrixApi.eventCounter++}',
|
||||
|
|
@ -2299,7 +2299,7 @@ class FakeMatrixApi extends MockClient {
|
|||
'event_id': '\$event${FakeMatrixApi.eventCounter++}',
|
||||
},
|
||||
'/client/v3/rooms/!localpart%3Aexample.com/typing/%40alice%3Aexample.com':
|
||||
(var req) => <String, dynamic>{},
|
||||
(var req) => <String, Object?>{},
|
||||
'/client/v3/rooms/!1234%3Aexample.com/send/m.room.message/1234':
|
||||
(var reqI) => {
|
||||
'event_id': '\$event${FakeMatrixApi.eventCounter++}',
|
||||
|
|
@ -2309,27 +2309,27 @@ class FakeMatrixApi extends MockClient {
|
|||
'event_id': '\$event${FakeMatrixApi.eventCounter++}',
|
||||
},
|
||||
'/client/v3/user/%40test%3AfakeServer.notExisting/rooms/!localpart%3Aserver.abc/tags/m.favourite':
|
||||
(var req) => <String, dynamic>{},
|
||||
(var req) => <String, Object?>{},
|
||||
'/client/v3/user/%40alice%3Aexample.com/rooms/!localpart%3Aexample.com/tags/testtag':
|
||||
(var req) => <String, dynamic>{},
|
||||
(var req) => <String, Object?>{},
|
||||
'/client/v3/user/%40alice%3Aexample.com/account_data/test.account.data':
|
||||
(var req) => <String, dynamic>{},
|
||||
(var req) => <String, Object?>{},
|
||||
'/client/v3/user/%40test%3AfakeServer.notExisting/account_data/best%20animal':
|
||||
(var req) => <String, dynamic>{},
|
||||
(var req) => <String, Object?>{},
|
||||
'/client/v3/user/%40alice%3Aexample.com/rooms/1234/account_data/test.account.data':
|
||||
(var req) => <String, dynamic>{},
|
||||
(var req) => <String, Object?>{},
|
||||
'/client/v3/user/%40test%3AfakeServer.notExisting/rooms/!localpart%3Aserver.abc/account_data/com.famedly.marked_unread':
|
||||
(var req) => <String, dynamic>{},
|
||||
(var req) => <String, Object?>{},
|
||||
'/client/v3/user/%40test%3AfakeServer.notExisting/account_data/m.direct':
|
||||
(var req) => <String, dynamic>{},
|
||||
(var req) => <String, Object?>{},
|
||||
'/client/v3/user/%40othertest%3AfakeServer.notExisting/account_data/m.direct':
|
||||
(var req) => <String, dynamic>{},
|
||||
(var req) => <String, Object?>{},
|
||||
'/client/v3/profile/%40alice%3Aexample.com/displayname': (var reqI) =>
|
||||
<String, dynamic>{},
|
||||
<String, Object?>{},
|
||||
'/client/v3/profile/%40alice%3Aexample.com/avatar_url': (var reqI) =>
|
||||
<String, dynamic>{},
|
||||
<String, Object?>{},
|
||||
'/client/v3/profile/%40test%3AfakeServer.notExisting/avatar_url':
|
||||
(var reqI) => <String, dynamic>{},
|
||||
(var reqI) => <String, Object?>{},
|
||||
'/client/v3/rooms/!localpart%3Aserver.abc/state/m.room.encryption':
|
||||
(var reqI) => {'event_id': 'YUwRidLecu:example.com'},
|
||||
'/client/v3/rooms/!localpart%3Aserver.abc/state/m.room.avatar':
|
||||
|
|
@ -2355,8 +2355,8 @@ class FakeMatrixApi extends MockClient {
|
|||
'event_id': '42',
|
||||
},
|
||||
'/client/v3/directory/list/room/!localpart%3Aexample.com': (var req) =>
|
||||
<String, dynamic>{},
|
||||
'/client/v3/room_keys/version/5': (var req) => <String, dynamic>{},
|
||||
<String, Object?>{},
|
||||
'/client/v3/room_keys/version/5': (var req) => <String, Object?>{},
|
||||
'/client/v3/room_keys/keys/${Uri.encodeComponent('!726s6s6q:example.com')}/${Uri.encodeComponent('ciM/JWTPrmiWPPZNkRLDPQYf9AW/I46bxyLSr+Bx5oU')}?version=5':
|
||||
(var req) => {
|
||||
'etag': 'asdf',
|
||||
|
|
@ -2374,18 +2374,18 @@ class FakeMatrixApi extends MockClient {
|
|||
},
|
||||
'DELETE': {
|
||||
'/unknown/token': (var req) => {'errcode': 'M_UNKNOWN_TOKEN'},
|
||||
'/client/v3/devices/QBUAZIFURK': (var req) => <String, dynamic>{},
|
||||
'/client/v3/devices/QBUAZIFURK': (var req) => <String, Object?>{},
|
||||
'/client/v3/directory/room/%23testalias%3Aexample.com': (var reqI) =>
|
||||
<String, dynamic>{},
|
||||
<String, Object?>{},
|
||||
'/client/v3/pushrules/global/content/nocake': (var req) =>
|
||||
<String, dynamic>{},
|
||||
<String, Object?>{},
|
||||
'/client/v3/pushrules/global/override/!localpart%3Aserver.abc':
|
||||
(var req) => <String, dynamic>{},
|
||||
(var req) => <String, Object?>{},
|
||||
'/client/v3/user/%40test%3AfakeServer.notExisting/rooms/!localpart%3Aserver.abc/tags/m.favourite':
|
||||
(var req) => <String, dynamic>{},
|
||||
(var req) => <String, Object?>{},
|
||||
'/client/v3/user/%40alice%3Aexample.com/rooms/!localpart%3Aexample.com/tags/testtag':
|
||||
(var req) => <String, dynamic>{},
|
||||
'/client/v3/room_keys/version/5': (var req) => <String, dynamic>{},
|
||||
(var req) => <String, Object?>{},
|
||||
'/client/v3/room_keys/version/5': (var req) => <String, Object?>{},
|
||||
'/client/v3/room_keys/keys/${Uri.encodeComponent('!726s6s6q:example.com')}/${Uri.encodeComponent('ciM/JWTPrmiWPPZNkRLDPQYf9AW/I46bxyLSr+Bx5oU')}?version=5':
|
||||
(var req) => {
|
||||
'etag': 'asdf',
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ class MatrixApi extends Api {
|
|||
Never unexpectedResponse(http.BaseResponse response, Uint8List body) {
|
||||
if (response.statusCode >= 400 && response.statusCode < 500) {
|
||||
final resp = json.decode(utf8.decode(body));
|
||||
if (resp is Map<String, dynamic>) {
|
||||
if (resp is Map<String, Object?>) {
|
||||
throw MatrixException.fromJson(resp);
|
||||
}
|
||||
}
|
||||
|
|
@ -82,12 +82,12 @@ class MatrixApi extends Api {
|
|||
/// );
|
||||
/// ```
|
||||
///
|
||||
Future<Map<String, dynamic>> request(
|
||||
Future<Map<String, Object?>> request(
|
||||
RequestType type,
|
||||
String action, {
|
||||
dynamic data = '',
|
||||
String contentType = 'application/json',
|
||||
Map<String, dynamic>? query,
|
||||
Map<String, Object?>? query,
|
||||
}) async {
|
||||
if (homeserver == null) {
|
||||
throw ('No homeserver specified.');
|
||||
|
|
@ -108,7 +108,7 @@ class MatrixApi extends Api {
|
|||
}
|
||||
|
||||
late http.Response resp;
|
||||
Map<String, dynamic>? jsonResp = <String, dynamic>{};
|
||||
Map<String, Object?>? jsonResp = <String, Object?>{};
|
||||
try {
|
||||
switch (type) {
|
||||
case RequestType.GET:
|
||||
|
|
@ -138,7 +138,7 @@ class MatrixApi extends Api {
|
|||
jsonString = '{"chunk":$jsonString}';
|
||||
}
|
||||
jsonResp = jsonDecode(jsonString)
|
||||
as Map<String, dynamic>?; // May throw FormatException
|
||||
as Map<String, Object?>?; // May throw FormatException
|
||||
} catch (e, s) {
|
||||
throw MatrixConnectionException(e, s);
|
||||
}
|
||||
|
|
@ -153,8 +153,8 @@ class MatrixApi extends Api {
|
|||
/// https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-keys-query
|
||||
Future<Map<String, int>> uploadKeys(
|
||||
{MatrixDeviceKeys? deviceKeys,
|
||||
Map<String, dynamic>? oneTimeKeys,
|
||||
Map<String, dynamic>? fallbackKeys}) async {
|
||||
Map<String, Object?>? oneTimeKeys,
|
||||
Map<String, Object?>? fallbackKeys}) async {
|
||||
final response = await request(
|
||||
RequestType.POST,
|
||||
'/client/v3/keys/upload',
|
||||
|
|
|
|||
|
|
@ -29,12 +29,12 @@ class AuthenticationData {
|
|||
|
||||
AuthenticationData({this.type, this.session});
|
||||
|
||||
AuthenticationData.fromJson(Map<String, dynamic> json)
|
||||
AuthenticationData.fromJson(Map<String, Object?> json)
|
||||
: type = json['type'] as String?,
|
||||
session = json['session'] as String?;
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
Map<String, Object?> toJson() {
|
||||
final data = <String, Object?>{};
|
||||
if (type != null) data['type'] = type;
|
||||
if (session != null) data['session'] = session;
|
||||
return data;
|
||||
|
|
|
|||
|
|
@ -31,10 +31,10 @@ class AuthenticationIdentifier {
|
|||
|
||||
AuthenticationIdentifier({required this.type});
|
||||
|
||||
AuthenticationIdentifier.fromJson(Map<String, dynamic> json)
|
||||
AuthenticationIdentifier.fromJson(Map<String, Object?> json)
|
||||
: type = json['type'] as String;
|
||||
|
||||
factory AuthenticationIdentifier.subFromJson(Map<String, dynamic> json) {
|
||||
factory AuthenticationIdentifier.subFromJson(Map<String, Object?> json) {
|
||||
switch (json['type']) {
|
||||
case AuthenticationIdentifierTypes.userId:
|
||||
return AuthenticationUserIdentifier.fromJson(json);
|
||||
|
|
@ -47,8 +47,8 @@ class AuthenticationIdentifier {
|
|||
}
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
Map<String, Object?> toJson() {
|
||||
final data = <String, Object?>{};
|
||||
data['type'] = type;
|
||||
return data;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,14 +40,14 @@ class AuthenticationPassword extends AuthenticationData {
|
|||
session: session,
|
||||
);
|
||||
|
||||
AuthenticationPassword.fromJson(Map<String, dynamic> json)
|
||||
AuthenticationPassword.fromJson(Map<String, Object?> json)
|
||||
: password = json['password'] as String,
|
||||
identifier = AuthenticationIdentifier.subFromJson(
|
||||
json['identifier'] as Map<String, dynamic>),
|
||||
json['identifier'] as Map<String, Object?>),
|
||||
super.fromJson(json);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
Map<String, Object?> toJson() {
|
||||
final data = super.toJson();
|
||||
data['password'] = password;
|
||||
data['identifier'] = identifier.toJson();
|
||||
|
|
|
|||
|
|
@ -31,13 +31,13 @@ class AuthenticationPhoneIdentifier extends AuthenticationIdentifier {
|
|||
AuthenticationPhoneIdentifier({required this.country, required this.phone})
|
||||
: super(type: AuthenticationIdentifierTypes.phone);
|
||||
|
||||
AuthenticationPhoneIdentifier.fromJson(Map<String, dynamic> json)
|
||||
AuthenticationPhoneIdentifier.fromJson(Map<String, Object?> json)
|
||||
: country = json['country'] as String,
|
||||
phone = json['phone'] as String,
|
||||
super.fromJson(json);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
Map<String, Object?> toJson() {
|
||||
final data = super.toJson();
|
||||
data['country'] = country;
|
||||
data['phone'] = phone;
|
||||
|
|
|
|||
|
|
@ -33,12 +33,12 @@ class AuthenticationRecaptcha extends AuthenticationData {
|
|||
session: session,
|
||||
);
|
||||
|
||||
AuthenticationRecaptcha.fromJson(Map<String, dynamic> json)
|
||||
AuthenticationRecaptcha.fromJson(Map<String, Object?> json)
|
||||
: response = json['response'] as String,
|
||||
super.fromJson(json);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
Map<String, Object?> toJson() {
|
||||
final data = super.toJson();
|
||||
data['response'] = response;
|
||||
return data;
|
||||
|
|
|
|||
|
|
@ -32,13 +32,13 @@ class AuthenticationThirdPartyIdentifier extends AuthenticationIdentifier {
|
|||
{required this.medium, required this.address})
|
||||
: super(type: AuthenticationIdentifierTypes.thirdParty);
|
||||
|
||||
AuthenticationThirdPartyIdentifier.fromJson(Map<String, dynamic> json)
|
||||
AuthenticationThirdPartyIdentifier.fromJson(Map<String, Object?> json)
|
||||
: medium = json['medium'] as String,
|
||||
address = json['address'] as String,
|
||||
super.fromJson(json);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
Map<String, Object?> toJson() {
|
||||
final data = super.toJson();
|
||||
data['medium'] = medium;
|
||||
data['address'] = address;
|
||||
|
|
|
|||
|
|
@ -37,16 +37,16 @@ class AuthenticationThreePidCreds extends AuthenticationData {
|
|||
session: session,
|
||||
);
|
||||
|
||||
AuthenticationThreePidCreds.fromJson(Map<String, dynamic> json)
|
||||
AuthenticationThreePidCreds.fromJson(Map<String, Object?> json)
|
||||
: super.fromJson(json) {
|
||||
final creds = json['threepid_creds'];
|
||||
if (creds is Map<String, dynamic>) {
|
||||
if (creds is Map<String, Object?>) {
|
||||
threepidCreds = ThreepidCreds.fromJson(creds);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
Map<String, Object?> toJson() {
|
||||
final data = super.toJson();
|
||||
data['threepid_creds'] = threepidCreds.toJson();
|
||||
return data;
|
||||
|
|
@ -65,14 +65,14 @@ class ThreepidCreds {
|
|||
this.idServer,
|
||||
this.idAccessToken});
|
||||
|
||||
ThreepidCreds.fromJson(Map<String, dynamic> json)
|
||||
ThreepidCreds.fromJson(Map<String, Object?> json)
|
||||
: sid = json['sid'] as String,
|
||||
clientSecret = json['client_secret'] as String,
|
||||
idServer = json['id_server'] as String?,
|
||||
idAccessToken = json['id_access_token'] as String?;
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
Map<String, Object?> toJson() {
|
||||
final data = <String, Object?>{};
|
||||
data['sid'] = sid;
|
||||
data['client_secret'] = clientSecret;
|
||||
if (idServer != null) data['id_server'] = idServer;
|
||||
|
|
|
|||
|
|
@ -36,13 +36,13 @@ class AuthenticationToken extends AuthenticationData {
|
|||
session: session,
|
||||
);
|
||||
|
||||
AuthenticationToken.fromJson(Map<String, dynamic> json)
|
||||
AuthenticationToken.fromJson(Map<String, Object?> json)
|
||||
: token = json['token'] as String,
|
||||
txnId = json['txn_id'] as String?,
|
||||
super.fromJson(json);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
Map<String, Object?> toJson() {
|
||||
final data = super.toJson();
|
||||
data['token'] = token;
|
||||
data['txn_id'] = txnId;
|
||||
|
|
|
|||
|
|
@ -30,12 +30,12 @@ class AuthenticationUserIdentifier extends AuthenticationIdentifier {
|
|||
AuthenticationUserIdentifier({required this.user})
|
||||
: super(type: AuthenticationIdentifierTypes.userId);
|
||||
|
||||
AuthenticationUserIdentifier.fromJson(Map<String, dynamic> json)
|
||||
AuthenticationUserIdentifier.fromJson(Map<String, Object?> json)
|
||||
: user = json['user'] as String,
|
||||
super.fromJson(json);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
Map<String, Object?> toJson() {
|
||||
final data = super.toJson();
|
||||
data['user'] = user;
|
||||
return data;
|
||||
|
|
|
|||
|
|
@ -25,19 +25,19 @@ import '../utils/map_copy_extension.dart';
|
|||
|
||||
class BasicEvent {
|
||||
String type;
|
||||
Map<String, dynamic> content;
|
||||
Map<String, Object?> content;
|
||||
|
||||
BasicEvent({
|
||||
required this.type,
|
||||
required this.content,
|
||||
});
|
||||
|
||||
BasicEvent.fromJson(Map<String, dynamic> json)
|
||||
BasicEvent.fromJson(Map<String, Object?> json)
|
||||
: type = json['type'] as String,
|
||||
content = (json['content'] as Map<String, dynamic>).copy();
|
||||
content = (json['content'] as Map<String, Object?>).copy();
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
Map<String, Object?> toJson() {
|
||||
final data = <String, Object?>{};
|
||||
data['type'] = type;
|
||||
data['content'] = content;
|
||||
return data;
|
||||
|
|
|
|||
|
|
@ -28,16 +28,16 @@ class BasicEventWithSender extends BasicEvent {
|
|||
|
||||
BasicEventWithSender(
|
||||
{required String type,
|
||||
required Map<String, dynamic> content,
|
||||
required Map<String, Object?> content,
|
||||
required this.senderId})
|
||||
: super(type: type, content: content);
|
||||
|
||||
BasicEventWithSender.fromJson(Map<String, dynamic> json)
|
||||
BasicEventWithSender.fromJson(Map<String, Object?> json)
|
||||
: senderId = json['sender'] as String,
|
||||
super.fromJson(json);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
Map<String, Object?> toJson() {
|
||||
final data = super.toJson();
|
||||
data['sender'] = senderId;
|
||||
return data;
|
||||
|
|
|
|||
|
|
@ -28,19 +28,19 @@ class BasicRoomEvent extends BasicEvent {
|
|||
|
||||
BasicRoomEvent({
|
||||
this.roomId,
|
||||
required Map<String, dynamic> content,
|
||||
required Map<String, Object?> content,
|
||||
required String type,
|
||||
}) : super(
|
||||
content: content,
|
||||
type: type,
|
||||
);
|
||||
|
||||
BasicRoomEvent.fromJson(Map<String, dynamic> json)
|
||||
BasicRoomEvent.fromJson(Map<String, Object?> json)
|
||||
: roomId = json['room_id'] as String?,
|
||||
super.fromJson(json);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
Map<String, Object?> toJson() {
|
||||
final data = super.toJson();
|
||||
if (roomId != null) data['room_id'] = roomId;
|
||||
return data;
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ class ChildrenState extends StrippedStateEvent {
|
|||
|
||||
ChildrenState({
|
||||
required String type,
|
||||
required Map<String, dynamic> content,
|
||||
required Map<String, Object?> content,
|
||||
required String senderId,
|
||||
required String stateKey,
|
||||
required this.originServerTs,
|
||||
|
|
@ -38,13 +38,13 @@ class ChildrenState extends StrippedStateEvent {
|
|||
senderId: senderId,
|
||||
stateKey: stateKey);
|
||||
|
||||
ChildrenState.fromJson(Map<String, dynamic> json)
|
||||
ChildrenState.fromJson(Map<String, Object?> json)
|
||||
: originServerTs = DateTime.fromMillisecondsSinceEpoch(
|
||||
json['origin_server_ts'] as int),
|
||||
super.fromJson(json);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
Map<String, Object?> toJson() {
|
||||
final data = super.toJson();
|
||||
data['origin_server_ts'] = originServerTs.millisecondsSinceEpoch;
|
||||
return data;
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ class ForwardedRoomKeyContent extends RoomKeyContent {
|
|||
String senderClaimedEd25519Key;
|
||||
List<String> forwardingCurve25519KeyChain;
|
||||
|
||||
ForwardedRoomKeyContent.fromJson(Map<String, dynamic> json)
|
||||
ForwardedRoomKeyContent.fromJson(Map<String, Object?> json)
|
||||
: senderKey = json.tryGet('sender_key', TryGet.required) ?? '',
|
||||
senderClaimedEd25519Key =
|
||||
json.tryGet('sender_claimed_ed25519_key', TryGet.required) ?? '',
|
||||
|
|
@ -45,7 +45,7 @@ class ForwardedRoomKeyContent extends RoomKeyContent {
|
|||
super.fromJson(json);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
Map<String, Object?> toJson() {
|
||||
final data = super.toJson();
|
||||
data['sender_key'] = senderKey;
|
||||
data['sender_claimed_ed25519_key'] = senderClaimedEd25519Key;
|
||||
|
|
|
|||
|
|
@ -66,31 +66,31 @@ List<String> imagePackUsageToJson(
|
|||
|
||||
class ImagePackContent {
|
||||
// we want to preserve potential custom keys in this object
|
||||
final Map<String, dynamic> _json;
|
||||
final Map<String, Object?> _json;
|
||||
|
||||
Map<String, ImagePackImageContent> images;
|
||||
ImagePackPackContent pack;
|
||||
|
||||
ImagePackContent({required this.images, required this.pack}) : _json = {};
|
||||
|
||||
ImagePackContent.fromJson(Map<String, dynamic> json)
|
||||
ImagePackContent.fromJson(Map<String, Object?> json)
|
||||
: _json = Map.fromEntries(json.entries.where(
|
||||
(e) => !['images', 'pack', 'emoticons', 'short'].contains(e.key))),
|
||||
pack = ImagePackPackContent.fromJson(
|
||||
json.tryGetMap<String, dynamic>('pack') ?? {}),
|
||||
images = json.tryGetMap<String, dynamic>('images')?.catchMap((k, v) =>
|
||||
json.tryGetMap<String, Object?>('pack') ?? {}),
|
||||
images = json.tryGetMap<String, Object?>('images')?.catchMap((k, v) =>
|
||||
MapEntry(
|
||||
k,
|
||||
ImagePackImageContent.fromJson(
|
||||
v as Map<String, dynamic>))) ??
|
||||
v as Map<String, Object?>))) ??
|
||||
// the "emoticons" key needs a small migration on the key, ":string:" --> "string"
|
||||
json.tryGetMap<String, dynamic>('emoticons')?.catchMap((k, v) =>
|
||||
json.tryGetMap<String, Object?>('emoticons')?.catchMap((k, v) =>
|
||||
MapEntry(
|
||||
k.startsWith(':') && k.endsWith(':')
|
||||
? k.substring(1, k.length - 1)
|
||||
: k,
|
||||
ImagePackImageContent.fromJson(
|
||||
v as Map<String, dynamic>))) ??
|
||||
v as Map<String, Object?>))) ??
|
||||
// the "short" key was still just a map from shortcode to mxc uri
|
||||
json.tryGetMap<String, String>('short')?.catchMap((k, v) =>
|
||||
MapEntry(
|
||||
|
|
@ -100,7 +100,7 @@ class ImagePackContent {
|
|||
ImagePackImageContent(url: Uri.parse(v)))) ??
|
||||
{};
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
Map<String, Object?> toJson() => {
|
||||
..._json,
|
||||
'images': images.map((k, v) => MapEntry(k, v.toJson())),
|
||||
'pack': pack.toJson(),
|
||||
|
|
@ -109,25 +109,25 @@ class ImagePackContent {
|
|||
|
||||
class ImagePackImageContent {
|
||||
// we want to preserve potential custom keys in this object
|
||||
final Map<String, dynamic> _json;
|
||||
final Map<String, Object?> _json;
|
||||
|
||||
Uri url;
|
||||
String? body;
|
||||
Map<String, dynamic>? info;
|
||||
Map<String, Object?>? info;
|
||||
List<ImagePackUsage>? usage;
|
||||
|
||||
ImagePackImageContent({required this.url, this.body, this.info, this.usage})
|
||||
: _json = {};
|
||||
|
||||
ImagePackImageContent.fromJson(Map<String, dynamic> json)
|
||||
ImagePackImageContent.fromJson(Map<String, Object?> json)
|
||||
: _json = Map.fromEntries(json.entries
|
||||
.where((e) => !['url', 'body', 'info'].contains(e.key))),
|
||||
url = Uri.parse(json['url'] as String),
|
||||
body = json.tryGet('body'),
|
||||
info = json.tryGetMap<String, dynamic>('info'),
|
||||
info = json.tryGetMap<String, Object?>('info'),
|
||||
usage = imagePackUsageFromJson(json.tryGetList<String>('usage'));
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
Map<String, Object?> toJson() {
|
||||
return {
|
||||
...Map.from(_json)..remove('usage'),
|
||||
'url': url.toString(),
|
||||
|
|
@ -141,7 +141,7 @@ class ImagePackImageContent {
|
|||
|
||||
class ImagePackPackContent {
|
||||
// we want to preserve potential custom keys in this object
|
||||
final Map<String, dynamic> _json;
|
||||
final Map<String, Object?> _json;
|
||||
|
||||
String? displayName;
|
||||
Uri? avatarUrl;
|
||||
|
|
@ -152,7 +152,7 @@ class ImagePackPackContent {
|
|||
{this.displayName, this.avatarUrl, this.usage, this.attribution})
|
||||
: _json = {};
|
||||
|
||||
ImagePackPackContent.fromJson(Map<String, dynamic> json)
|
||||
ImagePackPackContent.fromJson(Map<String, Object?> json)
|
||||
: _json = Map.fromEntries(json.entries.where((e) =>
|
||||
!['display_name', 'avatar_url', 'attribution'].contains(e.key))),
|
||||
displayName = json.tryGet('display_name'),
|
||||
|
|
@ -161,7 +161,7 @@ class ImagePackPackContent {
|
|||
usage = imagePackUsageFromJson(json.tryGetList<String>('usage')),
|
||||
attribution = json.tryGet('attribution');
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
Map<String, Object?> toJson() {
|
||||
return {
|
||||
...Map.from(_json)..remove('usage'),
|
||||
if (displayName != null) 'display_name': displayName,
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ import '../../utils/try_get_map_extension.dart';
|
|||
|
||||
class OlmPlaintextPayload {
|
||||
String? type;
|
||||
Map<String, dynamic>? content;
|
||||
Map<String, Object?>? content;
|
||||
String? sender;
|
||||
String? recipient;
|
||||
Map<String, String>? recipientKeys;
|
||||
|
|
@ -40,7 +40,7 @@ class OlmPlaintextPayload {
|
|||
this.keys,
|
||||
}) : super();
|
||||
|
||||
factory OlmPlaintextPayload.fromJson(Map<String, dynamic> json) =>
|
||||
factory OlmPlaintextPayload.fromJson(Map<String, Object?> json) =>
|
||||
OlmPlaintextPayload(
|
||||
sender: json.tryGet('sender', TryGet.required),
|
||||
type: json.tryGet('type', TryGet.required),
|
||||
|
|
@ -50,8 +50,8 @@ class OlmPlaintextPayload {
|
|||
keys: json.tryGetMap('keys', TryGet.required),
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
Map<String, Object?> toJson() {
|
||||
final data = <String, Object?>{};
|
||||
if (type != null) data['type'] = type;
|
||||
if (sender != null) data['sender'] = sender;
|
||||
if (content != null) data['content'] = content;
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ class RoomEncryptedContent {
|
|||
String? ciphertextMegolm;
|
||||
Map<String, CiphertextInfo>? ciphertextOlm;
|
||||
|
||||
RoomEncryptedContent.fromJson(Map<String, dynamic> json)
|
||||
RoomEncryptedContent.fromJson(Map<String, Object?> json)
|
||||
: algorithm = json.tryGet('algorithm', TryGet.required) ?? '',
|
||||
senderKey = json.tryGet('sender_key', TryGet.required) ?? '',
|
||||
deviceId = json.tryGet('device_id'),
|
||||
|
|
@ -47,12 +47,12 @@ class RoomEncryptedContent {
|
|||
ciphertextMegolm = json.tryGet('ciphertext', TryGet.silent),
|
||||
// filter out invalid/incomplete CiphertextInfos
|
||||
ciphertextOlm = json
|
||||
.tryGet<Map<String, dynamic>>('ciphertext', TryGet.silent)
|
||||
.tryGet<Map<String, Object?>>('ciphertext', TryGet.silent)
|
||||
?.catchMap((k, v) => MapEntry(
|
||||
k, CiphertextInfo.fromJson(v as Map<String, dynamic>)));
|
||||
k, CiphertextInfo.fromJson(v as Map<String, Object?>)));
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
Map<String, Object?> toJson() {
|
||||
final data = <String, Object?>{};
|
||||
data['algorithm'] = algorithm;
|
||||
data['sender_key'] = senderKey;
|
||||
if (deviceId != null) {
|
||||
|
|
@ -80,12 +80,12 @@ class CiphertextInfo {
|
|||
String body;
|
||||
int type;
|
||||
|
||||
CiphertextInfo.fromJson(Map<String, dynamic> json)
|
||||
CiphertextInfo.fromJson(Map<String, Object?> json)
|
||||
: body = json['body'] as String,
|
||||
type = json['type'] as int;
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
Map<String, Object?> toJson() {
|
||||
final data = <String, Object?>{};
|
||||
data['body'] = body;
|
||||
data['type'] = type;
|
||||
return data;
|
||||
|
|
|
|||
|
|
@ -34,13 +34,13 @@ class RoomEncryptionContent {
|
|||
int? rotationPeriodMs;
|
||||
int? rotationPeriodMsgs;
|
||||
|
||||
RoomEncryptionContent.fromJson(Map<String, dynamic> json)
|
||||
RoomEncryptionContent.fromJson(Map<String, Object?> json)
|
||||
: algorithm = json.tryGet('algorithm', TryGet.required) ?? '',
|
||||
rotationPeriodMs = json.tryGet('rotation_period_ms'),
|
||||
rotationPeriodMsgs = json.tryGet('rotation_period_msgs');
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
Map<String, Object?> toJson() {
|
||||
final data = <String, Object?>{};
|
||||
data['algorithm'] = algorithm;
|
||||
if (rotationPeriodMs != null) {
|
||||
data['rotation_period_ms'] = rotationPeriodMs;
|
||||
|
|
|
|||
|
|
@ -40,14 +40,14 @@ class RoomKeyContent {
|
|||
required this.sessionId,
|
||||
required this.sessionKey});
|
||||
|
||||
RoomKeyContent.fromJson(Map<String, dynamic> json)
|
||||
RoomKeyContent.fromJson(Map<String, Object?> json)
|
||||
: algorithm = json.tryGet('algorithm', TryGet.required) ?? '',
|
||||
roomId = json.tryGet('room_id', TryGet.required) ?? '',
|
||||
sessionId = json.tryGet('session_id', TryGet.required) ?? '',
|
||||
sessionKey = json.tryGet('session_key', TryGet.required) ?? '';
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
Map<String, Object?> toJson() {
|
||||
final data = <String, Object?>{};
|
||||
data['algorithm'] = algorithm;
|
||||
data['room_id'] = roomId;
|
||||
data['session_id'] = sessionId;
|
||||
|
|
|
|||
|
|
@ -35,8 +35,8 @@ class RoomKeyRequestContent {
|
|||
String requestingDeviceId;
|
||||
String requestId;
|
||||
|
||||
RoomKeyRequestContent.fromJson(Map<String, dynamic> json)
|
||||
: body = ((Map<String, dynamic>? x) => x != null
|
||||
RoomKeyRequestContent.fromJson(Map<String, Object?> json)
|
||||
: body = ((Map<String, Object?>? x) => x != null
|
||||
? RequestedKeyInfo.fromJson(x)
|
||||
: null)(json.tryGet('body')),
|
||||
action = json.tryGet('action', TryGet.required) ?? '',
|
||||
|
|
@ -44,8 +44,8 @@ class RoomKeyRequestContent {
|
|||
json.tryGet('requesting_device_id', TryGet.required) ?? '',
|
||||
requestId = json.tryGet('request_id', TryGet.required) ?? '';
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
Map<String, Object?> toJson() {
|
||||
final data = <String, Object?>{};
|
||||
if (body != null) data['body'] = body!.toJson();
|
||||
data['action'] = action;
|
||||
data['requesting_device_id'] = requestingDeviceId;
|
||||
|
|
@ -66,14 +66,14 @@ class RequestedKeyInfo {
|
|||
required this.sessionId,
|
||||
required this.senderKey});
|
||||
|
||||
RequestedKeyInfo.fromJson(Map<String, dynamic> json)
|
||||
RequestedKeyInfo.fromJson(Map<String, Object?> json)
|
||||
: algorithm = json.tryGet('algorithm', TryGet.required) ?? '',
|
||||
roomId = json.tryGet('room_id', TryGet.required) ?? '',
|
||||
sessionId = json.tryGet('session_id', TryGet.required) ?? '',
|
||||
senderKey = json.tryGet('sender_key', TryGet.required) ?? '';
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
Map<String, Object?> toJson() {
|
||||
final data = <String, Object?>{};
|
||||
data['algorithm'] = algorithm;
|
||||
data['room_id'] = roomId;
|
||||
data['session_id'] = sessionId;
|
||||
|
|
|
|||
|
|
@ -35,11 +35,11 @@ class SecretStorageDefaultKeyContent {
|
|||
|
||||
SecretStorageDefaultKeyContent({required this.key});
|
||||
|
||||
SecretStorageDefaultKeyContent.fromJson(Map<String, dynamic> json)
|
||||
SecretStorageDefaultKeyContent.fromJson(Map<String, Object?> json)
|
||||
: key = json.tryGet('key', TryGet.required);
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
Map<String, Object?> toJson() {
|
||||
final data = <String, Object?>{};
|
||||
if (key != null) data['key'] = key;
|
||||
return data;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,16 +37,16 @@ class SecretStorageKeyContent {
|
|||
|
||||
SecretStorageKeyContent();
|
||||
|
||||
SecretStorageKeyContent.fromJson(Map<String, dynamic> json)
|
||||
: passphrase = ((Map<String, dynamic>? x) => x != null
|
||||
SecretStorageKeyContent.fromJson(Map<String, Object?> json)
|
||||
: passphrase = ((Map<String, Object?>? x) => x != null
|
||||
? PassphraseInfo.fromJson(x)
|
||||
: null)(json.tryGet('passphrase')),
|
||||
iv = json.tryGet('iv'),
|
||||
mac = json.tryGet('mac'),
|
||||
algorithm = json.tryGet('algorithm');
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
Map<String, Object?> toJson() {
|
||||
final data = <String, Object?>{};
|
||||
if (passphrase != null) data['passphrase'] = passphrase!.toJson();
|
||||
if (iv != null) data['iv'] = iv;
|
||||
if (mac != null) data['mac'] = mac;
|
||||
|
|
@ -69,14 +69,14 @@ class PassphraseInfo {
|
|||
required this.iterations,
|
||||
this.bits});
|
||||
|
||||
PassphraseInfo.fromJson(Map<String, dynamic> json)
|
||||
PassphraseInfo.fromJson(Map<String, Object?> json)
|
||||
: algorithm = json.tryGet('algorithm', TryGet.required),
|
||||
salt = json.tryGet('salt', TryGet.required),
|
||||
iterations = json.tryGet('iterations', TryGet.required),
|
||||
bits = json.tryGet('bits');
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
Map<String, Object?> toJson() {
|
||||
final data = <String, Object?>{};
|
||||
data['algorithm'] = algorithm;
|
||||
data['salt'] = salt;
|
||||
data['iterations'] = iterations;
|
||||
|
|
|
|||
|
|
@ -33,13 +33,13 @@ class TombstoneContent {
|
|||
String body;
|
||||
String replacementRoom;
|
||||
|
||||
TombstoneContent.fromJson(Map<String, dynamic> json)
|
||||
TombstoneContent.fromJson(Map<String, Object?> json)
|
||||
: body = json.tryGet('body', TryGet.required) ?? '',
|
||||
replacementRoom =
|
||||
json.tryGet('replacement_room', TryGet.required) ?? '';
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
Map<String, Object?> toJson() {
|
||||
final data = <String, Object?>{};
|
||||
data['body'] = body;
|
||||
data['replacement_room'] = replacementRoom;
|
||||
return data;
|
||||
|
|
|
|||
|
|
@ -28,13 +28,13 @@ class MatrixEvent extends StrippedStateEvent {
|
|||
String eventId;
|
||||
String? roomId;
|
||||
DateTime originServerTs;
|
||||
Map<String, dynamic>? unsigned;
|
||||
Map<String, dynamic>? prevContent;
|
||||
Map<String, Object?>? unsigned;
|
||||
Map<String, Object?>? prevContent;
|
||||
String? redacts;
|
||||
|
||||
MatrixEvent({
|
||||
required String type,
|
||||
required Map<String, dynamic> content,
|
||||
required Map<String, Object?> content,
|
||||
required String senderId,
|
||||
String? stateKey,
|
||||
required this.eventId,
|
||||
|
|
@ -49,18 +49,18 @@ class MatrixEvent extends StrippedStateEvent {
|
|||
senderId: senderId,
|
||||
stateKey: stateKey);
|
||||
|
||||
MatrixEvent.fromJson(Map<String, dynamic> json)
|
||||
MatrixEvent.fromJson(Map<String, Object?> json)
|
||||
: eventId = json['event_id'] as String,
|
||||
roomId = json['room_id'] as String?,
|
||||
originServerTs = DateTime.fromMillisecondsSinceEpoch(
|
||||
json['origin_server_ts'] as int),
|
||||
unsigned = (json['unsigned'] as Map<String, dynamic>?)?.copy(),
|
||||
prevContent = (json['prev_content'] as Map<String, dynamic>?)?.copy(),
|
||||
unsigned = (json['unsigned'] as Map<String, Object?>?)?.copy(),
|
||||
prevContent = (json['prev_content'] as Map<String, Object?>?)?.copy(),
|
||||
redacts = json['redacts'] as String?,
|
||||
super.fromJson(json);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
Map<String, Object?> toJson() {
|
||||
final data = super.toJson();
|
||||
data['event_id'] = eventId;
|
||||
data['origin_server_ts'] = originServerTs.millisecondsSinceEpoch;
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ enum MatrixError {
|
|||
|
||||
/// Represents a special response from the Homeserver for errors.
|
||||
class MatrixException implements Exception {
|
||||
final Map<String, dynamic> raw;
|
||||
final Map<String, Object?> raw;
|
||||
|
||||
/// The unique identifier for this error.
|
||||
String get errcode =>
|
||||
|
|
@ -81,9 +81,9 @@ class MatrixException implements Exception {
|
|||
http.Response? response;
|
||||
|
||||
MatrixException(http.Response this.response)
|
||||
: raw = json.decode(response.body) as Map<String, dynamic>;
|
||||
: raw = json.decode(response.body) as Map<String, Object?>;
|
||||
|
||||
MatrixException.fromJson(Map<String, dynamic> content) : raw = content;
|
||||
MatrixException.fromJson(Map<String, Object?> content) : raw = content;
|
||||
|
||||
@override
|
||||
String toString() => '$errcode: $errorMessage';
|
||||
|
|
@ -110,7 +110,7 @@ class MatrixException implements Exception {
|
|||
/// doesn't need additional authentication, then this is null.
|
||||
List<AuthenticationFlow>? get authenticationFlows => raw
|
||||
.tryGet<List<dynamic>>('flows')
|
||||
?.whereType<Map<String, dynamic>>()
|
||||
?.whereType<Map<String, Object?>>()
|
||||
.map((flow) => flow['stages'])
|
||||
.whereType<List<dynamic>>()
|
||||
.map((stages) =>
|
||||
|
|
@ -120,8 +120,8 @@ class MatrixException implements Exception {
|
|||
/// This section contains any information that the client will need to know in order to use a given type
|
||||
/// of authentication. For each authentication type presented, that type may be present as a key in this
|
||||
/// dictionary. For example, the public part of an OAuth client ID could be given here.
|
||||
Map<String, dynamic>? get authenticationParams =>
|
||||
raw.tryGetMap<String, dynamic>('params');
|
||||
Map<String, Object?>? get authenticationParams =>
|
||||
raw.tryGetMap<String, Object?>('params');
|
||||
|
||||
/// Returns the list of already completed authentication flows from previous requests.
|
||||
List<String> get completedAuthenticationFlows =>
|
||||
|
|
|
|||
|
|
@ -30,25 +30,25 @@ abstract class MatrixSignableKey {
|
|||
|
||||
Map<String, String> keys;
|
||||
Map<String, Map<String, String>>? signatures;
|
||||
Map<String, dynamic>? unsigned;
|
||||
Map<String, Object?>? unsigned;
|
||||
|
||||
MatrixSignableKey(this.userId, this.keys, this.signatures, {this.unsigned});
|
||||
|
||||
// This object is used for signing so we need the raw json too
|
||||
Map<String, dynamic>? _json;
|
||||
Map<String, Object?>? _json;
|
||||
|
||||
MatrixSignableKey.fromJson(Map<String, dynamic> json)
|
||||
MatrixSignableKey.fromJson(Map<String, Object?> json)
|
||||
: _json = json,
|
||||
userId = json['user_id'] as String,
|
||||
keys = Map<String, String>.from(json['keys'] as Map<String, dynamic>),
|
||||
keys = Map<String, String>.from(json['keys'] as Map<String, Object?>),
|
||||
// we need to manually copy to ensure that our map is Map<String, Map<String, String>>
|
||||
signatures = (() {
|
||||
final orig = json.tryGetMap<String, dynamic>('signatures');
|
||||
final orig = json.tryGetMap<String, Object?>('signatures');
|
||||
final res = <String, Map<String, String>>{};
|
||||
for (final entry
|
||||
in (orig?.entries ?? <MapEntry<String, dynamic>>[])) {
|
||||
in (orig?.entries ?? <MapEntry<String, Object?>>[])) {
|
||||
final deviceSigs = entry.value;
|
||||
if (deviceSigs is Map<String, dynamic>) {
|
||||
if (deviceSigs is Map<String, Object?>) {
|
||||
for (final nestedEntry in deviceSigs.entries) {
|
||||
final nestedValue = nestedEntry.value;
|
||||
if (nestedValue is String) {
|
||||
|
|
@ -60,10 +60,10 @@ abstract class MatrixSignableKey {
|
|||
}
|
||||
return res;
|
||||
}()),
|
||||
unsigned = json.tryGetMap<String, dynamic>('unsigned')?.copy();
|
||||
unsigned = json.tryGetMap<String, Object?>('unsigned')?.copy();
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = _json ?? <String, dynamic>{};
|
||||
Map<String, Object?> toJson() {
|
||||
final data = _json ?? <String, Object?>{};
|
||||
data['user_id'] = userId;
|
||||
data['keys'] = keys;
|
||||
|
||||
|
|
@ -87,19 +87,19 @@ class MatrixCrossSigningKey extends MatrixSignableKey {
|
|||
this.usage,
|
||||
Map<String, String> keys,
|
||||
Map<String, Map<String, String>> signatures, {
|
||||
Map<String, dynamic>? unsigned,
|
||||
Map<String, Object?>? unsigned,
|
||||
}) : super(userId, keys, signatures, unsigned: unsigned);
|
||||
|
||||
@override
|
||||
String? get identifier => keys.values.first;
|
||||
|
||||
@override
|
||||
MatrixCrossSigningKey.fromJson(Map<String, dynamic> json)
|
||||
MatrixCrossSigningKey.fromJson(Map<String, Object?> json)
|
||||
: usage = json.tryGetList<String>('usage') ?? [],
|
||||
super.fromJson(json);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
Map<String, Object?> toJson() {
|
||||
final data = super.toJson();
|
||||
data['usage'] = usage;
|
||||
return data;
|
||||
|
|
@ -119,20 +119,20 @@ class MatrixDeviceKeys extends MatrixSignableKey {
|
|||
this.algorithms,
|
||||
Map<String, String> keys,
|
||||
Map<String, Map<String, String>> signatures, {
|
||||
Map<String, dynamic>? unsigned,
|
||||
Map<String, Object?>? unsigned,
|
||||
}) : super(userId, keys, signatures, unsigned: unsigned);
|
||||
|
||||
@override
|
||||
String? get identifier => deviceId;
|
||||
|
||||
@override
|
||||
MatrixDeviceKeys.fromJson(Map<String, dynamic> json)
|
||||
MatrixDeviceKeys.fromJson(Map<String, Object?> json)
|
||||
: algorithms = json.tryGetList<String>('algorithms') ?? [],
|
||||
deviceId = json['device_id'] as String,
|
||||
super.fromJson(json);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
Map<String, Object?> toJson() {
|
||||
final data = super.toJson();
|
||||
data['device_id'] = deviceId;
|
||||
data['algorithms'] = algorithms;
|
||||
|
|
|
|||
|
|
@ -27,8 +27,8 @@ import 'presence_content.dart';
|
|||
class Presence extends BasicEventWithSender {
|
||||
PresenceContent presence;
|
||||
|
||||
Presence.fromJson(Map<String, dynamic> json)
|
||||
Presence.fromJson(Map<String, Object?> json)
|
||||
: presence =
|
||||
PresenceContent.fromJson(json['content'] as Map<String, dynamic>),
|
||||
PresenceContent.fromJson(json['content'] as Map<String, Object?>),
|
||||
super.fromJson(json);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,15 +29,15 @@ class PresenceContent {
|
|||
String? statusMsg;
|
||||
bool? currentlyActive;
|
||||
|
||||
PresenceContent.fromJson(Map<String, dynamic> json)
|
||||
PresenceContent.fromJson(Map<String, Object?> json)
|
||||
: presence = PresenceType.values.firstWhere(
|
||||
(p) => p.toString().split('.').last == json['presence']),
|
||||
lastActiveAgo = json.tryGet<int>('last_active_ago'),
|
||||
statusMsg = json.tryGet<String>('status_msg'),
|
||||
currentlyActive = json.tryGet<bool>('currently_active');
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
Map<String, Object?> toJson() {
|
||||
final data = <String, Object?>{};
|
||||
data['presence'] = presence.toString().split('.').last;
|
||||
if (lastActiveAgo != null) {
|
||||
data['last_active_ago'] = lastActiveAgo;
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ class RoomKeysSingleKey {
|
|||
int firstMessageIndex;
|
||||
int forwardedCount;
|
||||
bool isVerified;
|
||||
Map<String, dynamic> sessionData;
|
||||
Map<String, Object?> sessionData;
|
||||
|
||||
RoomKeysSingleKey(
|
||||
{required this.firstMessageIndex,
|
||||
|
|
@ -35,14 +35,14 @@ class RoomKeysSingleKey {
|
|||
required this.isVerified,
|
||||
required this.sessionData});
|
||||
|
||||
RoomKeysSingleKey.fromJson(Map<String, dynamic> json)
|
||||
RoomKeysSingleKey.fromJson(Map<String, Object?> json)
|
||||
: firstMessageIndex = json['first_message_index'] as int,
|
||||
forwardedCount = json['forwarded_count'] as int,
|
||||
isVerified = json['is_verified'] as bool,
|
||||
sessionData = json['session_data'] as Map<String, dynamic>;
|
||||
sessionData = json['session_data'] as Map<String, Object?>;
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
Map<String, Object?> toJson() {
|
||||
final data = <String, Object?>{};
|
||||
data['first_message_index'] = firstMessageIndex;
|
||||
data['forwarded_count'] = forwardedCount;
|
||||
data['is_verified'] = isVerified;
|
||||
|
|
@ -56,12 +56,12 @@ class RoomKeysRoom {
|
|||
|
||||
RoomKeysRoom({required this.sessions});
|
||||
|
||||
RoomKeysRoom.fromJson(Map<String, dynamic> json)
|
||||
: sessions = (json['sessions'] as Map<String, dynamic>).map((k, v) =>
|
||||
MapEntry(k, RoomKeysSingleKey.fromJson(v as Map<String, dynamic>)));
|
||||
RoomKeysRoom.fromJson(Map<String, Object?> json)
|
||||
: sessions = (json['sessions'] as Map<String, Object?>).map((k, v) =>
|
||||
MapEntry(k, RoomKeysSingleKey.fromJson(v as Map<String, Object?>)));
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
Map<String, Object?> toJson() {
|
||||
final data = <String, Object?>{};
|
||||
data['sessions'] = sessions.map((k, v) => MapEntry(k, v.toJson()));
|
||||
return data;
|
||||
}
|
||||
|
|
@ -71,13 +71,13 @@ class RoomKeysUpdateResponse {
|
|||
String etag;
|
||||
int count;
|
||||
|
||||
RoomKeysUpdateResponse.fromJson(Map<String, dynamic> json)
|
||||
RoomKeysUpdateResponse.fromJson(Map<String, Object?> json)
|
||||
: etag = json.tryGet<String>('etag') ??
|
||||
'', // synapse replies an int but docs say string?
|
||||
count = json.tryGet<int>('count') ?? 0;
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
Map<String, Object?> toJson() {
|
||||
final data = <String, Object?>{};
|
||||
data['etag'] = etag;
|
||||
data['count'] = count;
|
||||
return data;
|
||||
|
|
|
|||
|
|
@ -26,15 +26,15 @@ class RoomSummary {
|
|||
int? mJoinedMemberCount;
|
||||
int? mInvitedMemberCount;
|
||||
|
||||
RoomSummary.fromJson(Map<String, dynamic> json)
|
||||
RoomSummary.fromJson(Map<String, Object?> json)
|
||||
: mHeroes = json['m.heroes'] != null
|
||||
? List<String>.from(json['m.heroes'] as List)
|
||||
: null,
|
||||
mJoinedMemberCount = json['m.joined_member_count'] as int?,
|
||||
mInvitedMemberCount = json['m.invited_member_count'] as int?;
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
Map<String, Object?> toJson() {
|
||||
final data = <String, Object?>{};
|
||||
if (mHeroes != null) {
|
||||
data['m.heroes'] = mHeroes;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,17 +28,17 @@ class StrippedStateEvent extends BasicEventWithSender {
|
|||
|
||||
StrippedStateEvent(
|
||||
{required String type,
|
||||
required Map<String, dynamic> content,
|
||||
required Map<String, Object?> content,
|
||||
required String senderId,
|
||||
this.stateKey})
|
||||
: super(type: type, content: content, senderId: senderId);
|
||||
|
||||
StrippedStateEvent.fromJson(Map<String, dynamic> json)
|
||||
StrippedStateEvent.fromJson(Map<String, Object?> json)
|
||||
: stateKey = json.tryGet<String>('state_key'),
|
||||
super.fromJson(json);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
Map<String, Object?> toJson() {
|
||||
final data = super.toJson();
|
||||
data['state_key'] = stateKey;
|
||||
return data;
|
||||
|
|
|
|||
|
|
@ -44,27 +44,27 @@ class SyncUpdate {
|
|||
this.deviceUnusedFallbackKeyTypes,
|
||||
});
|
||||
|
||||
SyncUpdate.fromJson(Map<String, dynamic> json)
|
||||
SyncUpdate.fromJson(Map<String, Object?> json)
|
||||
: nextBatch = json['next_batch'] as String,
|
||||
rooms = (() {
|
||||
final temp = json.tryGetMap<String, dynamic>('rooms');
|
||||
final temp = json.tryGetMap<String, Object?>('rooms');
|
||||
return temp != null ? RoomsUpdate.fromJson(temp) : null;
|
||||
}()),
|
||||
presence = json
|
||||
.tryGetMap<String, List<dynamic>>('presence')?['events']
|
||||
?.map((i) => Presence.fromJson(i as Map<String, dynamic>))
|
||||
?.map((i) => Presence.fromJson(i as Map<String, Object?>))
|
||||
.toList(),
|
||||
accountData = json
|
||||
.tryGetMap<String, List<dynamic>>('account_data')?['events']
|
||||
?.map((i) => BasicEvent.fromJson(i as Map<String, dynamic>))
|
||||
?.map((i) => BasicEvent.fromJson(i as Map<String, Object?>))
|
||||
.toList(),
|
||||
toDevice = json
|
||||
.tryGetMap<String, List<dynamic>>('to_device')?['events']
|
||||
?.map(
|
||||
(i) => BasicEventWithSender.fromJson(i as Map<String, dynamic>))
|
||||
(i) => BasicEventWithSender.fromJson(i as Map<String, Object?>))
|
||||
.toList(),
|
||||
deviceLists = (() {
|
||||
final temp = json.tryGetMap<String, dynamic>('device_lists');
|
||||
final temp = json.tryGetMap<String, Object?>('device_lists');
|
||||
return temp != null ? DeviceListsUpdate.fromJson(temp) : null;
|
||||
}()),
|
||||
deviceOneTimeKeysCount =
|
||||
|
|
@ -74,8 +74,8 @@ class SyncUpdate {
|
|||
json.tryGetList<String>(
|
||||
'org.matrix.msc2732.device_unused_fallback_key_types');
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
Map<String, Object?> toJson() {
|
||||
final data = <String, Object?>{};
|
||||
data['next_batch'] = nextBatch;
|
||||
if (rooms != null) {
|
||||
data['rooms'] = rooms!.toJson();
|
||||
|
|
@ -121,17 +121,17 @@ class RoomsUpdate {
|
|||
this.leave,
|
||||
});
|
||||
|
||||
RoomsUpdate.fromJson(Map<String, dynamic> json) {
|
||||
join = json.tryGetMap<String, dynamic>('join')?.catchMap((k, v) =>
|
||||
MapEntry(k, JoinedRoomUpdate.fromJson(v as Map<String, dynamic>)));
|
||||
invite = json.tryGetMap<String, dynamic>('invite')?.catchMap((k, v) =>
|
||||
MapEntry(k, InvitedRoomUpdate.fromJson(v as Map<String, dynamic>)));
|
||||
leave = json.tryGetMap<String, dynamic>('leave')?.catchMap((k, v) =>
|
||||
MapEntry(k, LeftRoomUpdate.fromJson(v as Map<String, dynamic>)));
|
||||
RoomsUpdate.fromJson(Map<String, Object?> json) {
|
||||
join = json.tryGetMap<String, Object?>('join')?.catchMap((k, v) =>
|
||||
MapEntry(k, JoinedRoomUpdate.fromJson(v as Map<String, Object?>)));
|
||||
invite = json.tryGetMap<String, Object?>('invite')?.catchMap((k, v) =>
|
||||
MapEntry(k, InvitedRoomUpdate.fromJson(v as Map<String, Object?>)));
|
||||
leave = json.tryGetMap<String, Object?>('leave')?.catchMap((k, v) =>
|
||||
MapEntry(k, LeftRoomUpdate.fromJson(v as Map<String, Object?>)));
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
Map<String, Object?> toJson() {
|
||||
final data = <String, Object?>{};
|
||||
if (join != null) {
|
||||
data['join'] = join!.map((k, v) => MapEntry(k, v.toJson()));
|
||||
}
|
||||
|
|
@ -164,26 +164,26 @@ class JoinedRoomUpdate extends SyncRoomUpdate {
|
|||
this.unreadNotifications,
|
||||
});
|
||||
|
||||
JoinedRoomUpdate.fromJson(Map<String, dynamic> json)
|
||||
JoinedRoomUpdate.fromJson(Map<String, Object?> json)
|
||||
: summary = json.tryGetFromJson('summary', RoomSummary.fromJson),
|
||||
state = json
|
||||
.tryGetMap<String, List<dynamic>>('state')?['events']
|
||||
?.map((i) => MatrixEvent.fromJson(i as Map<String, dynamic>))
|
||||
?.map((i) => MatrixEvent.fromJson(i as Map<String, Object?>))
|
||||
.toList(),
|
||||
timeline = json.tryGetFromJson('timeline', TimelineUpdate.fromJson),
|
||||
ephemeral = json
|
||||
.tryGetMap<String, List<dynamic>>('ephemeral')?['events']
|
||||
?.map((i) => BasicRoomEvent.fromJson(i as Map<String, dynamic>))
|
||||
?.map((i) => BasicRoomEvent.fromJson(i as Map<String, Object?>))
|
||||
.toList(),
|
||||
accountData = json
|
||||
.tryGetMap<String, List<dynamic>>('account_data')?['events']
|
||||
?.map((i) => BasicRoomEvent.fromJson(i as Map<String, dynamic>))
|
||||
?.map((i) => BasicRoomEvent.fromJson(i as Map<String, Object?>))
|
||||
.toList(),
|
||||
unreadNotifications = json.tryGetFromJson(
|
||||
'unread_notifications', UnreadNotificationCounts.fromJson);
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
Map<String, Object?> toJson() {
|
||||
final data = <String, Object?>{};
|
||||
if (summary != null) {
|
||||
data['summary'] = summary!.toJson();
|
||||
}
|
||||
|
|
@ -217,14 +217,14 @@ class InvitedRoomUpdate extends SyncRoomUpdate {
|
|||
|
||||
InvitedRoomUpdate({this.inviteState});
|
||||
|
||||
InvitedRoomUpdate.fromJson(Map<String, dynamic> json)
|
||||
InvitedRoomUpdate.fromJson(Map<String, Object?> json)
|
||||
: inviteState = json
|
||||
.tryGetMap<String, List<dynamic>>('invite_state')?['events']
|
||||
?.map((i) => StrippedStateEvent.fromJson(i as Map<String, dynamic>))
|
||||
?.map((i) => StrippedStateEvent.fromJson(i as Map<String, Object?>))
|
||||
.toList();
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
Map<String, Object?> toJson() {
|
||||
final data = <String, Object?>{};
|
||||
if (inviteState != null) {
|
||||
data['invite_state'] = {
|
||||
'events': inviteState!.map((i) => i.toJson()).toList(),
|
||||
|
|
@ -245,19 +245,19 @@ class LeftRoomUpdate extends SyncRoomUpdate {
|
|||
this.accountData,
|
||||
});
|
||||
|
||||
LeftRoomUpdate.fromJson(Map<String, dynamic> json)
|
||||
LeftRoomUpdate.fromJson(Map<String, Object?> json)
|
||||
: state = json
|
||||
.tryGetMap<String, List<dynamic>>('state')?['events']
|
||||
?.map((i) => MatrixEvent.fromJson(i as Map<String, dynamic>))
|
||||
?.map((i) => MatrixEvent.fromJson(i as Map<String, Object?>))
|
||||
.toList(),
|
||||
timeline = json.tryGetFromJson('timeline', TimelineUpdate.fromJson),
|
||||
accountData = json
|
||||
.tryGetMap<String, List<dynamic>>('account_data')?['events']
|
||||
?.map((i) => BasicRoomEvent.fromJson(i as Map<String, dynamic>))
|
||||
?.map((i) => BasicRoomEvent.fromJson(i as Map<String, Object?>))
|
||||
.toList();
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
Map<String, Object?> toJson() {
|
||||
final data = <String, Object?>{};
|
||||
if (state != null) {
|
||||
data['state'] = {
|
||||
'events': state!.map((i) => i.toJson()).toList(),
|
||||
|
|
@ -286,16 +286,16 @@ class TimelineUpdate {
|
|||
this.prevBatch,
|
||||
});
|
||||
|
||||
TimelineUpdate.fromJson(Map<String, dynamic> json)
|
||||
TimelineUpdate.fromJson(Map<String, Object?> json)
|
||||
: events = json
|
||||
.tryGetList<Map<String, dynamic>>('events')
|
||||
.tryGetList<Map<String, Object?>>('events')
|
||||
?.map((v) => MatrixEvent.fromJson(v))
|
||||
.toList(),
|
||||
limited = json.tryGet<bool>('limited'),
|
||||
prevBatch = json.tryGet<String>('prev_batch');
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
Map<String, Object?> toJson() {
|
||||
final data = <String, Object?>{};
|
||||
if (events != null) {
|
||||
data['events'] = events!.map((i) => i.toJson()).toList();
|
||||
}
|
||||
|
|
@ -318,12 +318,12 @@ class UnreadNotificationCounts {
|
|||
this.highlightCount,
|
||||
});
|
||||
|
||||
UnreadNotificationCounts.fromJson(Map<String, dynamic> json)
|
||||
UnreadNotificationCounts.fromJson(Map<String, Object?> json)
|
||||
: highlightCount = json.tryGet<int>('highlight_count'),
|
||||
notificationCount = json.tryGet<int>('notification_count');
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
Map<String, Object?> toJson() {
|
||||
final data = <String, Object?>{};
|
||||
if (highlightCount != null) {
|
||||
data['highlight_count'] = highlightCount;
|
||||
}
|
||||
|
|
@ -343,12 +343,12 @@ class DeviceListsUpdate {
|
|||
this.left,
|
||||
});
|
||||
|
||||
DeviceListsUpdate.fromJson(Map<String, dynamic> json)
|
||||
DeviceListsUpdate.fromJson(Map<String, Object?> json)
|
||||
: changed = json.tryGetList<String>('changed') ?? [],
|
||||
left = json.tryGetList<String>('left') ?? [];
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
Map<String, Object?> toJson() {
|
||||
final data = <String, Object?>{};
|
||||
if (changed != null) {
|
||||
data['changed'] = changed;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,9 +21,9 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
extension MapCopyExtension on Map<String, dynamic> {
|
||||
extension MapCopyExtension on Map<String, Object?> {
|
||||
dynamic _copyValue(dynamic value) {
|
||||
if (value is Map<String, dynamic>) {
|
||||
if (value is Map<String, Object?>) {
|
||||
return value.copy();
|
||||
}
|
||||
if (value is List) {
|
||||
|
|
@ -33,8 +33,8 @@ extension MapCopyExtension on Map<String, dynamic> {
|
|||
}
|
||||
|
||||
/// Deep-copies a given json map
|
||||
Map<String, dynamic> copy() {
|
||||
final copy = Map<String, dynamic>.from(this);
|
||||
Map<String, Object?> copy() {
|
||||
final copy = Map<String, Object?>.from(this);
|
||||
for (final entry in copy.entries) {
|
||||
copy[entry.key] = _copyValue(entry.value);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ class _SilentLog implements TryGet {
|
|||
void call(String key, Type expected, Type actual) {}
|
||||
}
|
||||
|
||||
extension TryGetMapExtension on Map<String, dynamic> {
|
||||
extension TryGetMapExtension on Map<String, Object?> {
|
||||
T? tryGet<T extends Object>(String key, [TryGet log = TryGet.optional]) {
|
||||
final Object? value = this[key];
|
||||
if (value is! T) {
|
||||
|
|
@ -101,9 +101,9 @@ extension TryGetMapExtension on Map<String, dynamic> {
|
|||
}
|
||||
}
|
||||
|
||||
A? tryGetFromJson<A>(String key, A Function(Map<String, dynamic>) fromJson,
|
||||
A? tryGetFromJson<A>(String key, A Function(Map<String, Object?>) fromJson,
|
||||
[TryGet log = TryGet.optional]) {
|
||||
final value = tryGetMap<String, dynamic>(key, log);
|
||||
final value = tryGetMap<String, Object?>(key, log);
|
||||
|
||||
return value != null ? fromJson(value) : null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ import 'package:matrix_api_lite/matrix_api_lite.dart';
|
|||
void main() {
|
||||
group('Event Content tests', () {
|
||||
test('Room Encryption Content', () {
|
||||
Map<String, dynamic>? json = <String, dynamic>{
|
||||
Map<String, Object?>? json = <String, Object?>{
|
||||
'content': {
|
||||
'algorithm': 'm.megolm.v1.aes-sha2',
|
||||
'rotation_period_ms': 604800000,
|
||||
|
|
@ -44,12 +44,12 @@ void main() {
|
|||
'type': 'm.room.encryption',
|
||||
'unsigned': {'age': 1234}
|
||||
};
|
||||
json = jsonDecode(jsonEncode(json)) as Map<String, dynamic>?;
|
||||
json = jsonDecode(jsonEncode(json)) as Map<String, Object?>?;
|
||||
expect(MatrixEvent.fromJson(json!).parsedRoomEncryptionContent.toJson(),
|
||||
json['content']);
|
||||
});
|
||||
test('Room Encrypted Content', () {
|
||||
Map<String, dynamic>? json = <String, dynamic>{
|
||||
Map<String, Object?>? json = <String, Object?>{
|
||||
'content': {
|
||||
'algorithm': 'm.megolm.v1.aes-sha2',
|
||||
'ciphertext': 'AwgAEnACgAkLmt6qF84IK++J7UDH2Za1YVchHyprqTqsg...',
|
||||
|
|
@ -64,10 +64,10 @@ void main() {
|
|||
'type': 'm.room.encrypted',
|
||||
'unsigned': {'age': 1234}
|
||||
};
|
||||
json = jsonDecode(jsonEncode(json)) as Map<String, dynamic>?;
|
||||
json = jsonDecode(jsonEncode(json)) as Map<String, Object?>?;
|
||||
expect(MatrixEvent.fromJson(json!).parsedRoomEncryptedContent.toJson(),
|
||||
json['content']);
|
||||
json = <String, dynamic>{
|
||||
json = <String, Object?>{
|
||||
'content': {
|
||||
'algorithm': 'm.olm.v1.curve25519-aes-sha2',
|
||||
'ciphertext': {
|
||||
|
|
@ -85,12 +85,12 @@ void main() {
|
|||
'type': 'm.room.encrypted',
|
||||
'unsigned': {'age': 1234}
|
||||
};
|
||||
json = jsonDecode(jsonEncode(json)) as Map<String, dynamic>?;
|
||||
json = jsonDecode(jsonEncode(json)) as Map<String, Object?>?;
|
||||
expect(MatrixEvent.fromJson(json!).parsedRoomEncryptedContent.toJson(),
|
||||
json['content']);
|
||||
});
|
||||
test('Room Key Content', () {
|
||||
Map<String, dynamic>? json = <String, dynamic>{
|
||||
Map<String, Object?>? json = <String, Object?>{
|
||||
'content': {
|
||||
'algorithm': 'm.megolm.v1.aes-sha2',
|
||||
'room_id': '!Cuyf34gef24t:localhost',
|
||||
|
|
@ -99,12 +99,12 @@ void main() {
|
|||
},
|
||||
'type': 'm.room_key'
|
||||
};
|
||||
json = jsonDecode(jsonEncode(json)) as Map<String, dynamic>?;
|
||||
json = jsonDecode(jsonEncode(json)) as Map<String, Object?>?;
|
||||
expect(BasicEvent.fromJson(json!).parsedRoomKeyContent.toJson(),
|
||||
json['content']);
|
||||
});
|
||||
test('Room Key Request Content', () {
|
||||
Map<String, dynamic>? json = <String, dynamic>{
|
||||
Map<String, Object?>? json = <String, Object?>{
|
||||
'content': {
|
||||
'action': 'request_cancellation',
|
||||
'request_id': '1495474790150.19',
|
||||
|
|
@ -112,10 +112,10 @@ void main() {
|
|||
},
|
||||
'type': 'm.room_key_request'
|
||||
};
|
||||
json = jsonDecode(jsonEncode(json)) as Map<String, dynamic>?;
|
||||
json = jsonDecode(jsonEncode(json)) as Map<String, Object?>?;
|
||||
expect(BasicEvent.fromJson(json!).parsedRoomKeyRequestContent.toJson(),
|
||||
json['content']);
|
||||
json = <String, dynamic>{
|
||||
json = <String, Object?>{
|
||||
'content': {
|
||||
'action': 'request',
|
||||
'body': {
|
||||
|
|
@ -129,12 +129,12 @@ void main() {
|
|||
},
|
||||
'type': 'm.room_key_request'
|
||||
};
|
||||
json = jsonDecode(jsonEncode(json)) as Map<String, dynamic>?;
|
||||
json = jsonDecode(jsonEncode(json)) as Map<String, Object?>?;
|
||||
expect(BasicEvent.fromJson(json!).parsedRoomKeyRequestContent.toJson(),
|
||||
json['content']);
|
||||
});
|
||||
test('Forwarded Room Key Content', () {
|
||||
Map<String, dynamic>? json = <String, dynamic>{
|
||||
Map<String, Object?>? json = <String, Object?>{
|
||||
'content': {
|
||||
'algorithm': 'm.megolm.v1.aes-sha2',
|
||||
'forwarding_curve25519_key_chain': [
|
||||
|
|
@ -149,14 +149,14 @@ void main() {
|
|||
},
|
||||
'type': 'm.forwarded_room_key'
|
||||
};
|
||||
json = jsonDecode(jsonEncode(json)) as Map<String, dynamic>?;
|
||||
json = jsonDecode(jsonEncode(json)) as Map<String, Object?>?;
|
||||
expect(BasicEvent.fromJson(json!).parsedForwardedRoomKeyContent.toJson(),
|
||||
json['content']);
|
||||
});
|
||||
test('OLM Plaintext Payload', () {
|
||||
Map<String, dynamic>? json = <String, dynamic>{
|
||||
Map<String, Object?>? json = <String, Object?>{
|
||||
'type': '<type of the plaintext event>',
|
||||
'content': <String, dynamic>{
|
||||
'content': <String, Object?>{
|
||||
'msgtype': 'm.text',
|
||||
'body': 'Hello world',
|
||||
},
|
||||
|
|
@ -165,12 +165,12 @@ void main() {
|
|||
'recipient_keys': {'ed25519': '<our_ed25519_key>'},
|
||||
'keys': {'ed25519': '<sender_ed25519_key>'}
|
||||
};
|
||||
json = jsonDecode(jsonEncode(json)) as Map<String, dynamic>?;
|
||||
json = jsonDecode(jsonEncode(json)) as Map<String, Object?>?;
|
||||
expect(OlmPlaintextPayload.fromJson(json!).toJson(), json);
|
||||
});
|
||||
test('Image Pack Content', () {
|
||||
// basic parse / unparse
|
||||
var json = <String, dynamic>{
|
||||
var json = <String, Object?>{
|
||||
'type': 'some type',
|
||||
'content': {
|
||||
'images': {
|
||||
|
|
@ -191,12 +191,12 @@ void main() {
|
|||
'org.custom': 'blah',
|
||||
},
|
||||
};
|
||||
json = jsonDecode(jsonEncode(json)) as Map<String, dynamic>;
|
||||
json = jsonDecode(jsonEncode(json)) as Map<String, Object?>;
|
||||
expect(BasicEvent.fromJson(json).parsedImagePackContent.toJson(),
|
||||
json['content']);
|
||||
|
||||
// emoticons migration
|
||||
json = <String, dynamic>{
|
||||
json = <String, Object?>{
|
||||
'type': 'some type',
|
||||
'content': {
|
||||
'emoticons': {
|
||||
|
|
@ -206,7 +206,7 @@ void main() {
|
|||
},
|
||||
},
|
||||
};
|
||||
json = jsonDecode(jsonEncode(json)) as Map<String, dynamic>;
|
||||
json = jsonDecode(jsonEncode(json)) as Map<String, Object?>;
|
||||
expect(
|
||||
BasicEvent.fromJson(json)
|
||||
.parsedImagePackContent
|
||||
|
|
@ -216,7 +216,7 @@ void main() {
|
|||
'url': 'mxc://example.org/beep',
|
||||
});
|
||||
|
||||
json = <String, dynamic>{
|
||||
json = <String, Object?>{
|
||||
'type': 'some type',
|
||||
'content': {
|
||||
'short': {
|
||||
|
|
@ -224,7 +224,7 @@ void main() {
|
|||
},
|
||||
},
|
||||
};
|
||||
json = jsonDecode(jsonEncode(json)) as Map<String, dynamic>;
|
||||
json = jsonDecode(jsonEncode(json)) as Map<String, Object?>;
|
||||
expect(
|
||||
BasicEvent.fromJson(json)
|
||||
.parsedImagePackContent
|
||||
|
|
@ -235,15 +235,15 @@ void main() {
|
|||
});
|
||||
|
||||
// invalid url for image
|
||||
json = <String, dynamic>{
|
||||
json = <String, Object?>{
|
||||
'type': 'some type',
|
||||
'content': {
|
||||
'images': {
|
||||
'emote': <String, dynamic>{},
|
||||
'emote': <String, Object?>{},
|
||||
},
|
||||
},
|
||||
};
|
||||
json = jsonDecode(jsonEncode(json)) as Map<String, dynamic>;
|
||||
json = jsonDecode(jsonEncode(json)) as Map<String, Object?>;
|
||||
expect(BasicEvent.fromJson(json).parsedImagePackContent.images['emote'],
|
||||
null);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -28,21 +28,21 @@ import 'package:matrix_api_lite/matrix_api_lite.dart';
|
|||
void main() {
|
||||
group('Map-copy-extension', () {
|
||||
test('it should work', () {
|
||||
final original = <String, dynamic>{
|
||||
final original = <String, Object?>{
|
||||
'attr': 'fox',
|
||||
'child': <String, dynamic>{
|
||||
'child': <String, Object?>{
|
||||
'attr': 'bunny',
|
||||
'list': [1, 2],
|
||||
},
|
||||
};
|
||||
final copy = original.copy();
|
||||
(original['child'] as Map<String, dynamic>)['attr'] = 'raccoon';
|
||||
expect((copy['child'] as Map<String, dynamic>)['attr'], 'bunny');
|
||||
((original['child'] as Map<String, dynamic>)['list'] as List<int>).add(3);
|
||||
expect((copy['child'] as Map<String, dynamic>)['list'], [1, 2]);
|
||||
(original['child'] as Map<String, Object?>)['attr'] = 'raccoon';
|
||||
expect((copy['child'] as Map<String, Object?>)['attr'], 'bunny');
|
||||
((original['child'] as Map<String, Object?>)['list'] as List<int>).add(3);
|
||||
expect((copy['child'] as Map<String, Object?>)['list'], [1, 2]);
|
||||
});
|
||||
test('should do arrays', () {
|
||||
final original = <String, dynamic>{
|
||||
final original = <String, Object?>{
|
||||
'arr': [
|
||||
[1, 2],
|
||||
{'beep': 'boop'},
|
||||
|
|
@ -51,9 +51,9 @@ void main() {
|
|||
final copy = original.copy();
|
||||
((original['arr'] as List)[0] as List<int>).add(3);
|
||||
expect((copy['arr'] as List)[0], [1, 2]);
|
||||
((original['arr'] as List)[1] as Map<String, dynamic>)['beep'] = 'blargh';
|
||||
((original['arr'] as List)[1] as Map<String, Object?>)['beep'] = 'blargh';
|
||||
expect(
|
||||
((copy['arr'] as List)[1] as Map<String, dynamic>)['beep'], 'boop');
|
||||
((copy['arr'] as List)[1] as Map<String, Object?>)['beep'], 'boop');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ import 'package:test/test.dart';
|
|||
import 'package:matrix_api_lite/fake_matrix_api.dart';
|
||||
import 'package:matrix_api_lite/matrix_api_lite.dart';
|
||||
|
||||
const emptyRequest = <String, dynamic>{};
|
||||
const emptyRequest = <String, Object?>{};
|
||||
|
||||
void main() {
|
||||
/// All Tests related to device keys
|
||||
|
|
@ -435,8 +435,8 @@ void main() {
|
|||
'types': ['type1'],
|
||||
},
|
||||
'include_leave': true,
|
||||
'state': <String, dynamic>{},
|
||||
'timeline': <String, dynamic>{},
|
||||
'state': <String, Object?>{},
|
||||
'timeline': <String, Object?>{},
|
||||
},
|
||||
'presence': {
|
||||
'limit': 10,
|
||||
|
|
@ -1082,7 +1082,7 @@ void main() {
|
|||
final devices = await matrixApi.getDevices();
|
||||
expect(
|
||||
(FakeMatrixApi.api['GET']!['/client/v3/devices']!.call(emptyRequest)
|
||||
as Map<String, dynamic>?)?['devices'],
|
||||
as Map<String, Object?>?)?['devices'],
|
||||
devices?.map((i) => i.toJson()).toList());
|
||||
|
||||
matrixApi.homeserver = matrixApi.accessToken = null;
|
||||
|
|
@ -1229,7 +1229,7 @@ void main() {
|
|||
final response = await matrixApi.getPushers();
|
||||
expect(
|
||||
FakeMatrixApi.api['GET']!['/client/v3/pushers']!
|
||||
.call(<String, dynamic>{}),
|
||||
.call(<String, Object?>{}),
|
||||
{'pushers': response?.map((i) => i.toJson()).toList()},
|
||||
);
|
||||
|
||||
|
|
@ -1268,7 +1268,7 @@ void main() {
|
|||
expect(
|
||||
FakeMatrixApi.api['GET']![
|
||||
'/client/v3/notifications?from=1234&limit=10&only=1234']!
|
||||
.call(<String, dynamic>{}),
|
||||
.call(<String, Object?>{}),
|
||||
response.toJson(),
|
||||
);
|
||||
|
||||
|
|
@ -1281,7 +1281,7 @@ void main() {
|
|||
final response = await matrixApi.getPushRules();
|
||||
expect(
|
||||
FakeMatrixApi.api['GET']!['/client/v3/pushrules']!
|
||||
.call(<String, dynamic>{}),
|
||||
.call(<String, Object?>{}),
|
||||
{'global': response.toJson()},
|
||||
);
|
||||
|
||||
|
|
@ -1295,7 +1295,7 @@ void main() {
|
|||
await matrixApi.getPushRule('global', PushRuleKind.content, 'nocake');
|
||||
expect(
|
||||
FakeMatrixApi.api['GET']!['/client/v3/pushrules/global/content/nocake']!
|
||||
.call(<String, dynamic>{}),
|
||||
.call(<String, Object?>{}),
|
||||
response.toJson(),
|
||||
);
|
||||
|
||||
|
|
@ -1396,7 +1396,7 @@ void main() {
|
|||
expect(
|
||||
FakeMatrixApi.api['GET']![
|
||||
'/client/v3/events?from=1234&timeout=10&room_id=%211234']!
|
||||
.call(<String, dynamic>{}),
|
||||
.call(<String, Object?>{}),
|
||||
response.toJson(),
|
||||
);
|
||||
|
||||
|
|
@ -1411,7 +1411,7 @@ void main() {
|
|||
expect(
|
||||
FakeMatrixApi.api['GET']![
|
||||
'/client/v3/user/%40alice%3Aexample.com/rooms/!localpart%3Aexample.com/tags']!
|
||||
.call(<String, dynamic>{}),
|
||||
.call(<String, Object?>{}),
|
||||
{'tags': response?.map((k, v) => MapEntry(k, v.toJson()))},
|
||||
);
|
||||
|
||||
|
|
@ -1636,14 +1636,14 @@ void main() {
|
|||
matrixApi.accessToken = '1234';
|
||||
|
||||
final algorithm = BackupAlgorithm.mMegolmBackupV1Curve25519AesSha2;
|
||||
final authData = <String, dynamic>{
|
||||
final authData = <String, Object?>{
|
||||
'public_key': 'GXYaxqhNhUK28zUdxOmEsFRguz+PzBsDlTLlF0O0RkM',
|
||||
'signatures': <String, Map<String, String>>{},
|
||||
};
|
||||
final ret = await matrixApi.postRoomKeysVersion(algorithm, authData);
|
||||
expect(
|
||||
(FakeMatrixApi.api['POST']!['/client/v3/room_keys/version']!
|
||||
.call(emptyRequest) as Map<String, dynamic>)['version'],
|
||||
.call(emptyRequest) as Map<String, Object?>)['version'],
|
||||
ret);
|
||||
});
|
||||
test('getRoomKeysVersionCurrent', () async {
|
||||
|
|
@ -1661,7 +1661,7 @@ void main() {
|
|||
matrixApi.accessToken = '1234';
|
||||
|
||||
final algorithm = BackupAlgorithm.mMegolmBackupV1Curve25519AesSha2;
|
||||
final authData = <String, dynamic>{
|
||||
final authData = <String, Object?>{
|
||||
'public_key': 'GXYaxqhNhUK28zUdxOmEsFRguz+PzBsDlTLlF0O0RkM',
|
||||
'signatures': <String, Map<String, String>>{},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -29,11 +29,11 @@ void main() {
|
|||
group('Try-get-map-extension', () {
|
||||
Logs().level = Level.verbose;
|
||||
test('it should work', () {
|
||||
final data = <String, dynamic>{
|
||||
final data = <String, Object?>{
|
||||
'str': 'foxies',
|
||||
'int': 42,
|
||||
'list': [2, 3, 4],
|
||||
'map': <String, dynamic>{
|
||||
'map': <String, Object?>{
|
||||
'beep': 'boop',
|
||||
},
|
||||
};
|
||||
|
|
@ -41,12 +41,12 @@ void main() {
|
|||
expect(data.tryGet<int>('str'), null);
|
||||
expect(data.tryGet<int>('int'), 42);
|
||||
expect(data.tryGet<List<int>>('list'), [2, 3, 4]);
|
||||
expect(data.tryGetMap<String, dynamic>('map')?.tryGet<String>('beep'),
|
||||
expect(data.tryGetMap<String, Object?>('map')?.tryGet<String>('beep'),
|
||||
'boop');
|
||||
expect(
|
||||
data.tryGetMap<String, dynamic>('map')?.tryGet<String>('meep'), null);
|
||||
data.tryGetMap<String, Object?>('map')?.tryGet<String>('meep'), null);
|
||||
expect(
|
||||
data.tryGetMap<String, dynamic>('pam')?.tryGet<String>('beep'), null);
|
||||
data.tryGetMap<String, Object?>('pam')?.tryGet<String>('beep'), null);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue