refactor: migrate to null safety
This commit is contained in:
parent
1b84de0b44
commit
d9c1fdb78a
|
|
@ -1,4 +1,4 @@
|
|||
// @dart=2.9
|
||||
|
||||
/* MIT License
|
||||
*
|
||||
* Copyright (C) 2019, 2020, 2021 Famedly GmbH
|
||||
|
|
@ -83,9 +83,9 @@ class FakeMatrixApi extends MockClient {
|
|||
if (!calledEndpoints.containsKey(action)) {
|
||||
calledEndpoints[action] = <dynamic>[];
|
||||
}
|
||||
calledEndpoints[action].add(data);
|
||||
if (api.containsKey(method) && api[method].containsKey(action)) {
|
||||
res = api[method][action](data);
|
||||
calledEndpoints[action]!.add(data);
|
||||
if (api.containsKey(method) && api[method]!.containsKey(action)) {
|
||||
res = api[method];
|
||||
if (res is Map && res.containsKey('errcode')) {
|
||||
statusCode = 405;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// @dart=2.9
|
||||
|
||||
/* MIT License
|
||||
*
|
||||
* Copyright (C) 2019, 2020, 2021 Famedly GmbH
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// @dart=2.9
|
||||
|
||||
/* MIT License
|
||||
*
|
||||
* Copyright (C) 2019, 2020, 2021 Famedly GmbH
|
||||
|
|
@ -54,13 +54,13 @@ String describeEnum(Object enumEntry) {
|
|||
|
||||
class MatrixApi extends Api {
|
||||
/// The homeserver this client is communicating with.
|
||||
Uri get homeserver => baseUri;
|
||||
set homeserver(Uri uri) => baseUri = uri;
|
||||
Uri? get homeserver => baseUri;
|
||||
set homeserver(Uri? uri) => baseUri = uri;
|
||||
|
||||
/// This is the access token for the matrix client. When it is undefined, then
|
||||
/// the user needs to sign in first.
|
||||
String get accessToken => bearerToken;
|
||||
set accessToken(String token) => bearerToken = token;
|
||||
String? get accessToken => bearerToken;
|
||||
set accessToken(String? token) => bearerToken = token;
|
||||
|
||||
@override
|
||||
Null unexpectedResponse(http.BaseResponse response, Uint8List responseBody) {
|
||||
|
|
@ -71,9 +71,9 @@ class MatrixApi extends Api {
|
|||
}
|
||||
|
||||
MatrixApi({
|
||||
Uri homeserver,
|
||||
String accessToken,
|
||||
http.Client httpClient,
|
||||
Uri? homeserver,
|
||||
String? accessToken,
|
||||
http.Client? httpClient,
|
||||
}) : super(
|
||||
httpClient: httpClient,
|
||||
baseUri: homeserver,
|
||||
|
|
@ -102,7 +102,7 @@ class MatrixApi extends Api {
|
|||
String action, {
|
||||
dynamic data = '',
|
||||
String contentType = 'application/json',
|
||||
Map<String, dynamic> query,
|
||||
Map<String, dynamic>? query,
|
||||
}) async {
|
||||
if (homeserver == null) {
|
||||
throw ('No homeserver specified.');
|
||||
|
|
@ -111,7 +111,7 @@ class MatrixApi extends Api {
|
|||
(!(data is String)) ? json = jsonEncode(data) : json = data;
|
||||
if (data is List<int> || action.startsWith('/media/r0/upload')) json = data;
|
||||
|
||||
final url = homeserver
|
||||
final url = homeserver!
|
||||
.resolveUri(Uri(path: '_matrix$action', queryParameters: query));
|
||||
|
||||
final headers = <String, String>{};
|
||||
|
|
@ -122,8 +122,8 @@ class MatrixApi extends Api {
|
|||
headers['Authorization'] = 'Bearer $accessToken';
|
||||
}
|
||||
|
||||
http.Response resp;
|
||||
var jsonResp = <String, dynamic>{};
|
||||
late http.Response resp;
|
||||
Map<String, dynamic>? jsonResp = <String, dynamic>{};
|
||||
try {
|
||||
switch (type) {
|
||||
case RequestType.GET:
|
||||
|
|
@ -153,7 +153,7 @@ class MatrixApi extends Api {
|
|||
jsonString = '\{"chunk":$jsonString\}';
|
||||
}
|
||||
jsonResp = jsonDecode(jsonString)
|
||||
as Map<String, dynamic>; // May throw FormatException
|
||||
as Map<String, dynamic>?; // May throw FormatException
|
||||
} catch (e, s) {
|
||||
throw MatrixConnectionException(e, s);
|
||||
}
|
||||
|
|
@ -161,7 +161,7 @@ class MatrixApi extends Api {
|
|||
throw MatrixException(resp);
|
||||
}
|
||||
|
||||
return jsonResp;
|
||||
return jsonResp!;
|
||||
}
|
||||
|
||||
/// The homeserver must check that the given email address is not already associated
|
||||
|
|
@ -173,9 +173,9 @@ class MatrixApi extends Api {
|
|||
String email,
|
||||
String clientSecret,
|
||||
int sendAttempt, {
|
||||
String nextLink,
|
||||
String idServer,
|
||||
String idAccessToken,
|
||||
String? nextLink,
|
||||
String? idServer,
|
||||
String? idAccessToken,
|
||||
}) async {
|
||||
final response = await request(
|
||||
RequestType.POST, '/client/r0/register/email/requestToken',
|
||||
|
|
@ -199,9 +199,9 @@ class MatrixApi extends Api {
|
|||
String phoneNumber,
|
||||
String clientSecret,
|
||||
int sendAttempt, {
|
||||
String nextLink,
|
||||
String idServer,
|
||||
String idAccessToken,
|
||||
String? nextLink,
|
||||
String? idServer,
|
||||
String? idAccessToken,
|
||||
}) async {
|
||||
final response = await request(
|
||||
RequestType.POST, '/client/r0/register/msisdn/requestToken',
|
||||
|
|
@ -225,9 +225,9 @@ class MatrixApi extends Api {
|
|||
String email,
|
||||
String clientSecret,
|
||||
int sendAttempt, {
|
||||
String nextLink,
|
||||
String idServer,
|
||||
String idAccessToken,
|
||||
String? nextLink,
|
||||
String? idServer,
|
||||
String? idAccessToken,
|
||||
}) async {
|
||||
final response = await request(
|
||||
RequestType.POST, '/client/r0/account/password/email/requestToken',
|
||||
|
|
@ -251,9 +251,9 @@ class MatrixApi extends Api {
|
|||
String phoneNumber,
|
||||
String clientSecret,
|
||||
int sendAttempt, {
|
||||
String nextLink,
|
||||
String idServer,
|
||||
String idAccessToken,
|
||||
String? nextLink,
|
||||
String? idServer,
|
||||
String? idAccessToken,
|
||||
}) async {
|
||||
final response = await request(
|
||||
RequestType.POST, '/client/r0/account/password/msisdn/requestToken',
|
||||
|
|
@ -275,9 +275,9 @@ class MatrixApi extends Api {
|
|||
String email,
|
||||
String clientSecret,
|
||||
int sendAttempt, {
|
||||
String nextLink,
|
||||
String idServer,
|
||||
String idAccessToken,
|
||||
String? nextLink,
|
||||
String? idServer,
|
||||
String? idAccessToken,
|
||||
}) async {
|
||||
final response = await request(
|
||||
RequestType.POST, '/client/r0/account/3pid/email/requestToken',
|
||||
|
|
@ -299,9 +299,9 @@ class MatrixApi extends Api {
|
|||
String phoneNumber,
|
||||
String clientSecret,
|
||||
int sendAttempt, {
|
||||
String nextLink,
|
||||
String idServer,
|
||||
String idAccessToken,
|
||||
String? nextLink,
|
||||
String? idServer,
|
||||
String? idAccessToken,
|
||||
}) async {
|
||||
final response = await request(
|
||||
RequestType.POST, '/client/r0/account/3pid/msisdn/requestToken',
|
||||
|
|
@ -323,7 +323,7 @@ class MatrixApi extends Api {
|
|||
/// https://matrix.org/docs/spec/client_server/r0.6.0#get-matrix-client-r0-rooms-roomid-state-eventtype-statekey
|
||||
Future<Map<String, dynamic>> requestStateContent(
|
||||
String roomId, String eventType,
|
||||
[String stateKey]) async {
|
||||
[String? stateKey]) async {
|
||||
var url =
|
||||
'/client/r0/rooms/${Uri.encodeComponent(roomId)}/state/${Uri.encodeComponent(eventType)}/';
|
||||
if (stateKey != null) {
|
||||
|
|
@ -364,9 +364,9 @@ class MatrixApi extends Api {
|
|||
/// Publishes end-to-end encryption keys for the device.
|
||||
/// 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 {
|
||||
{MatrixDeviceKeys? deviceKeys,
|
||||
Map<String, dynamic>? oneTimeKeys,
|
||||
Map<String, dynamic>? fallbackKeys}) async {
|
||||
final response = await request(
|
||||
RequestType.POST,
|
||||
'/client/r0/keys/upload',
|
||||
|
|
@ -385,10 +385,10 @@ class MatrixApi extends Api {
|
|||
/// Uploads your own cross-signing keys.
|
||||
/// https://github.com/matrix-org/matrix-doc/pull/2536
|
||||
Future<void> uploadDeviceSigningKeys({
|
||||
MatrixCrossSigningKey masterKey,
|
||||
MatrixCrossSigningKey selfSigningKey,
|
||||
MatrixCrossSigningKey userSigningKey,
|
||||
AuthenticationData auth,
|
||||
MatrixCrossSigningKey? masterKey,
|
||||
MatrixCrossSigningKey? selfSigningKey,
|
||||
MatrixCrossSigningKey? userSigningKey,
|
||||
AuthenticationData? auth,
|
||||
}) async {
|
||||
await request(
|
||||
RequestType.POST,
|
||||
|
|
@ -410,7 +410,7 @@ class MatrixApi extends Api {
|
|||
for (final key in keys) {
|
||||
if (key.identifier == null ||
|
||||
key.signatures == null ||
|
||||
key.signatures.isEmpty) {
|
||||
key.signatures!.isEmpty) {
|
||||
continue;
|
||||
}
|
||||
if (!payload.containsKey(key.userId)) {
|
||||
|
|
@ -437,7 +437,7 @@ class MatrixApi extends Api {
|
|||
/// for this user ID. The behaviour of this endpoint varies depending on the
|
||||
/// values in the JSON body.
|
||||
/// https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-pushers-set
|
||||
Future<void> postPusher(Pusher pusher, {bool append}) async {
|
||||
Future<void> postPusher(Pusher pusher, {bool? append}) async {
|
||||
final data = pusher.toJson();
|
||||
if (append != null) {
|
||||
data['append'] = append;
|
||||
|
|
@ -454,9 +454,9 @@ class MatrixApi extends Api {
|
|||
/// caller. This will block until an event is received, or until the timeout is reached.
|
||||
/// https://matrix.org/docs/spec/client_server/r0.6.1#get-matrix-client-r0-events
|
||||
Future<EventsSyncUpdate> getEvents({
|
||||
String from,
|
||||
int timeout,
|
||||
String roomId,
|
||||
String? from,
|
||||
int? timeout,
|
||||
String? roomId,
|
||||
}) async {
|
||||
final response =
|
||||
await request(RequestType.GET, '/client/r0/events', query: {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// @dart=2.9
|
||||
|
||||
/* MIT License
|
||||
*
|
||||
* Copyright (C) 2019, 2020, 2021 Famedly GmbH
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// @dart=2.9
|
||||
|
||||
/* MIT License
|
||||
*
|
||||
* Copyright (C) 2019, 2020, 2021 Famedly GmbH
|
||||
|
|
@ -24,9 +24,9 @@
|
|||
|
||||
class AuthenticationData {
|
||||
String type;
|
||||
String session;
|
||||
String?/*?*//*?*/ session;
|
||||
|
||||
AuthenticationData({this.type, this.session});
|
||||
AuthenticationData({required this.type, this.session});
|
||||
|
||||
AuthenticationData.fromJson(Map<String, dynamic> json)
|
||||
: type = json['type'],
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// @dart=2.9
|
||||
|
||||
/* MIT License
|
||||
*
|
||||
* Copyright (C) 2019, 2020, 2021 Famedly GmbH
|
||||
|
|
@ -30,7 +30,7 @@ import 'authentication_third_party_identifier.dart';
|
|||
class AuthenticationIdentifier {
|
||||
String type;
|
||||
|
||||
AuthenticationIdentifier({this.type});
|
||||
AuthenticationIdentifier({required this.type});
|
||||
|
||||
AuthenticationIdentifier.fromJson(Map<String, dynamic> json)
|
||||
: type = json['type'];
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// @dart=2.9
|
||||
|
||||
/* MIT License
|
||||
*
|
||||
* Copyright (C) 2019, 2020, 2021 Famedly GmbH
|
||||
|
|
@ -29,7 +29,7 @@ import 'authentication_identifier.dart';
|
|||
import 'authentication_types.dart';
|
||||
|
||||
class AuthenticationPassword extends AuthenticationData {
|
||||
String user;
|
||||
String? user;
|
||||
String password;
|
||||
|
||||
/// You may want to cast this as [AuthenticationUserIdentifier] or other
|
||||
|
|
@ -37,7 +37,7 @@ class AuthenticationPassword extends AuthenticationData {
|
|||
AuthenticationIdentifier identifier;
|
||||
|
||||
AuthenticationPassword(
|
||||
{String session, this.password, this.user, this.identifier})
|
||||
{String? session, required this.password, this.user, required this.identifier})
|
||||
: super(
|
||||
type: AuthenticationTypes.password,
|
||||
session: session,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// @dart=2.9
|
||||
|
||||
/* MIT License
|
||||
*
|
||||
* Copyright (C) 2019, 2020, 2021 Famedly GmbH
|
||||
|
|
@ -29,7 +29,7 @@ class AuthenticationPhoneIdentifier extends AuthenticationIdentifier {
|
|||
String country;
|
||||
String phone;
|
||||
|
||||
AuthenticationPhoneIdentifier({this.country, this.phone})
|
||||
AuthenticationPhoneIdentifier({required this.country, required this.phone})
|
||||
: super(type: AuthenticationIdentifierTypes.phone);
|
||||
|
||||
AuthenticationPhoneIdentifier.fromJson(Map<String, dynamic> json)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// @dart=2.9
|
||||
|
||||
/* MIT License
|
||||
*
|
||||
* Copyright (C) 2019, 2020, 2021 Famedly GmbH
|
||||
|
|
@ -28,7 +28,7 @@ import 'authentication_types.dart';
|
|||
class AuthenticationRecaptcha extends AuthenticationData {
|
||||
String response;
|
||||
|
||||
AuthenticationRecaptcha({String session, this.response})
|
||||
AuthenticationRecaptcha({required String session, required this.response})
|
||||
: super(
|
||||
type: AuthenticationTypes.recaptcha,
|
||||
session: session,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// @dart=2.9
|
||||
|
||||
/* MIT License
|
||||
*
|
||||
* Copyright (C) 2019, 2020, 2021 Famedly GmbH
|
||||
|
|
@ -29,7 +29,7 @@ class AuthenticationThirdPartyIdentifier extends AuthenticationIdentifier {
|
|||
String medium;
|
||||
String address;
|
||||
|
||||
AuthenticationThirdPartyIdentifier({this.medium, this.address})
|
||||
AuthenticationThirdPartyIdentifier({required this.medium, required this.address})
|
||||
: super(type: AuthenticationIdentifierTypes.thirdParty);
|
||||
|
||||
AuthenticationThirdPartyIdentifier.fromJson(Map<String, dynamic> json)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// @dart=2.9
|
||||
|
||||
/* MIT License
|
||||
*
|
||||
* Copyright (C) 2019, 2020, 2021 Famedly GmbH
|
||||
|
|
@ -29,9 +29,9 @@ import 'authentication_data.dart';
|
|||
/// Or phone number based identity:
|
||||
/// https://matrix.org/docs/spec/client_server/r0.6.1#phone-number-msisdn-based-identity-homeserver
|
||||
class AuthenticationThreePidCreds extends AuthenticationData {
|
||||
List<ThreepidCreds> threepidCreds;
|
||||
late List<ThreepidCreds> threepidCreds;
|
||||
|
||||
AuthenticationThreePidCreds({String session, String type, this.threepidCreds})
|
||||
AuthenticationThreePidCreds({String? session, required String type, required this.threepidCreds})
|
||||
: super(
|
||||
type: type,
|
||||
session: session,
|
||||
|
|
@ -65,13 +65,13 @@ class AuthenticationThreePidCreds extends AuthenticationData {
|
|||
}
|
||||
|
||||
class ThreepidCreds {
|
||||
String sid;
|
||||
String/*!*/ sid;
|
||||
String clientSecret;
|
||||
String idServer;
|
||||
String idAccessToken;
|
||||
|
||||
ThreepidCreds(
|
||||
{this.sid, this.clientSecret, this.idServer, this.idAccessToken});
|
||||
{required this.sid, required this.clientSecret, required this.idServer, required this.idAccessToken});
|
||||
|
||||
ThreepidCreds.fromJson(Map<String, dynamic> json)
|
||||
: sid = json['sid'],
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// @dart=2.9
|
||||
|
||||
/* MIT License
|
||||
*
|
||||
* Copyright (C) 2019, 2020, 2021 Famedly GmbH
|
||||
|
|
@ -27,9 +27,9 @@ import 'authentication_types.dart';
|
|||
|
||||
class AuthenticationToken extends AuthenticationData {
|
||||
String token;
|
||||
String txnId;
|
||||
String? txnId;
|
||||
|
||||
AuthenticationToken({String session, this.token, this.txnId})
|
||||
AuthenticationToken({String? session, required this.token, this.txnId})
|
||||
: super(
|
||||
type: AuthenticationTypes.token,
|
||||
session: session,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// @dart=2.9
|
||||
|
||||
/* MIT License
|
||||
*
|
||||
* Copyright (C) 2019, 2020, 2021 Famedly GmbH
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// @dart=2.9
|
||||
|
||||
/* MIT License
|
||||
*
|
||||
* Copyright (C) 2019, 2020, 2021 Famedly GmbH
|
||||
|
|
@ -28,7 +28,7 @@ import 'authentication_types.dart';
|
|||
class AuthenticationUserIdentifier extends AuthenticationIdentifier {
|
||||
String user;
|
||||
|
||||
AuthenticationUserIdentifier({this.user})
|
||||
AuthenticationUserIdentifier({required this.user})
|
||||
: super(type: AuthenticationIdentifierTypes.userId);
|
||||
|
||||
AuthenticationUserIdentifier.fromJson(Map<String, dynamic> json)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// @dart=2.9
|
||||
|
||||
/* MIT License
|
||||
*
|
||||
* Copyright (C) 2019, 2020, 2021 Famedly GmbH
|
||||
|
|
@ -29,8 +29,8 @@ class BasicEvent {
|
|||
Map<String, dynamic> content;
|
||||
|
||||
BasicEvent({
|
||||
this.type,
|
||||
this.content,
|
||||
required this.type,
|
||||
required this.content,
|
||||
});
|
||||
|
||||
BasicEvent.fromJson(Map<String, dynamic> json)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// @dart=2.9
|
||||
|
||||
/* MIT License
|
||||
*
|
||||
* Copyright (C) 2019, 2020, 2021 Famedly GmbH
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// @dart=2.9
|
||||
|
||||
/* MIT License
|
||||
*
|
||||
* Copyright (C) 2019, 2020, 2021 Famedly GmbH
|
||||
|
|
@ -25,12 +25,12 @@
|
|||
import 'basic_event.dart';
|
||||
|
||||
class BasicRoomEvent extends BasicEvent {
|
||||
String roomId;
|
||||
String? roomId;
|
||||
|
||||
BasicRoomEvent({
|
||||
this.roomId,
|
||||
Map<String, dynamic> content,
|
||||
String type,
|
||||
required Map<String, dynamic> content,
|
||||
required String type,
|
||||
}) : super(
|
||||
content: content,
|
||||
type: type,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// @dart=2.9
|
||||
|
||||
/* MIT License
|
||||
*
|
||||
* Copyright (C) 2019, 2020, 2021 Famedly GmbH
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// @dart=2.9
|
||||
|
||||
/* MIT License
|
||||
*
|
||||
* Copyright (C) 2019, 2020, 2021 Famedly GmbH
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// @dart=2.9
|
||||
|
||||
/* MIT License
|
||||
*
|
||||
* Copyright (C) 2019, 2020, 2021 Famedly GmbH
|
||||
|
|
@ -25,12 +25,12 @@
|
|||
import '../../utils/try_get_map_extension.dart';
|
||||
|
||||
class OlmPlaintextPayload {
|
||||
String type;
|
||||
Map<String, dynamic> content;
|
||||
String sender;
|
||||
String recipient;
|
||||
Map<String, String> recipientKeys;
|
||||
Map<String, String> keys;
|
||||
String? type;
|
||||
Map<String, dynamic>? content;
|
||||
String? sender;
|
||||
String? recipient;
|
||||
Map<String, String>? recipientKeys;
|
||||
Map<String, String>? keys;
|
||||
|
||||
OlmPlaintextPayload({
|
||||
this.type,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// @dart=2.9
|
||||
|
||||
/* MIT License
|
||||
*
|
||||
* Copyright (C) 2019, 2020, 2021 Famedly GmbH
|
||||
|
|
@ -35,10 +35,10 @@ extension RoomEncryptedContentBasicEventExtension on BasicEvent {
|
|||
class RoomEncryptedContent {
|
||||
String algorithm;
|
||||
String senderKey;
|
||||
String deviceId;
|
||||
String sessionId;
|
||||
String ciphertextMegolm;
|
||||
Map<String, CiphertextInfo> ciphertextOlm;
|
||||
String? deviceId;
|
||||
String? sessionId;
|
||||
String? ciphertextMegolm;
|
||||
Map<String, CiphertextInfo>? ciphertextOlm;
|
||||
|
||||
RoomEncryptedContent.fromJson(Map<String, dynamic> json)
|
||||
: algorithm = json.tryGet<String>('algorithm', ''),
|
||||
|
|
@ -68,7 +68,7 @@ class RoomEncryptedContent {
|
|||
data['ciphertext'] = ciphertextMegolm;
|
||||
}
|
||||
if (ciphertextOlm != null) {
|
||||
data['ciphertext'] = ciphertextOlm.map((k, v) => MapEntry(k, v.toJson()));
|
||||
data['ciphertext'] = ciphertextOlm!.map((k, v) => MapEntry(k, v.toJson()));
|
||||
if (ciphertextMegolm != null) {
|
||||
Logs().wtf(
|
||||
'ciphertextOlm and ciphertextMegolm are both set, which should never happen!');
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// @dart=2.9
|
||||
|
||||
/* MIT License
|
||||
*
|
||||
* Copyright (C) 2019, 2020, 2021 Famedly GmbH
|
||||
|
|
@ -32,13 +32,13 @@ extension RoomEncryptionContentBasicEventExtension on BasicEvent {
|
|||
|
||||
class RoomEncryptionContent {
|
||||
String algorithm;
|
||||
int rotationPeriodMs;
|
||||
int rotationPeriodMsgs;
|
||||
int? rotationPeriodMs;
|
||||
int? rotationPeriodMsgs;
|
||||
|
||||
RoomEncryptionContent.fromJson(Map<String, dynamic> json)
|
||||
: algorithm = json.tryGet<String>('algorithm', ''),
|
||||
rotationPeriodMs = json.tryGet<int>('rotation_period_ms'),
|
||||
rotationPeriodMsgs = json.tryGet<int>('rotation_period_msgs');
|
||||
rotationPeriodMs = json.tryGet<int?>('rotation_period_ms'),
|
||||
rotationPeriodMsgs = json.tryGet<int?>('rotation_period_msgs');
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// @dart=2.9
|
||||
|
||||
/* MIT License
|
||||
*
|
||||
* Copyright (C) 2019, 2020, 2021 Famedly GmbH
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// @dart=2.9
|
||||
|
||||
/* MIT License
|
||||
*
|
||||
* Copyright (C) 2019, 2020, 2021 Famedly GmbH
|
||||
|
|
@ -31,7 +31,7 @@ extension RoomKeyRequestContentBasicEventExtension on BasicEvent {
|
|||
}
|
||||
|
||||
class RoomKeyRequestContent {
|
||||
RequestedKeyInfo body;
|
||||
RequestedKeyInfo? body;
|
||||
String action;
|
||||
String requestingDeviceId;
|
||||
String requestId;
|
||||
|
|
@ -45,7 +45,7 @@ class RoomKeyRequestContent {
|
|||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
if (body != null) data['body'] = body.toJson();
|
||||
if (body != null) data['body'] = body!.toJson();
|
||||
data['action'] = action;
|
||||
data['requesting_device_id'] = requestingDeviceId;
|
||||
data['request_id'] = requestId;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// @dart=2.9
|
||||
|
||||
/* MIT License
|
||||
*
|
||||
* Copyright (C) 2019, 2020, 2021 Famedly GmbH
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// @dart=2.9
|
||||
|
||||
/* MIT License
|
||||
*
|
||||
* Copyright (C) 2019, 2020, 2021 Famedly GmbH
|
||||
|
|
@ -31,10 +31,10 @@ extension SecretStorageKeyContentBasicEventExtension on BasicEvent {
|
|||
}
|
||||
|
||||
class SecretStorageKeyContent {
|
||||
PassphraseInfo passphrase;
|
||||
String iv;
|
||||
String mac;
|
||||
String algorithm;
|
||||
PassphraseInfo? passphrase;
|
||||
String? iv;
|
||||
String? mac;
|
||||
String? algorithm;
|
||||
|
||||
SecretStorageKeyContent();
|
||||
|
||||
|
|
@ -42,13 +42,13 @@ class SecretStorageKeyContent {
|
|||
: passphrase = json['passphrase'] is Map<String, dynamic>
|
||||
? PassphraseInfo.fromJson(json['passphrase'])
|
||||
: null,
|
||||
iv = json.tryGet<String>('iv'),
|
||||
mac = json.tryGet<String>('mac'),
|
||||
algorithm = json.tryGet<String>('algorithm');
|
||||
iv = json.tryGet<String?>('iv'),
|
||||
mac = json.tryGet<String?>('mac'),
|
||||
algorithm = json.tryGet<String?>('algorithm');
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
if (passphrase != null) data['passphrase'] = passphrase.toJson();
|
||||
if (passphrase != null) data['passphrase'] = passphrase!.toJson();
|
||||
if (iv != null) data['iv'] = iv;
|
||||
if (mac != null) data['mac'] = mac;
|
||||
if (algorithm != null) data['algorithm'] = algorithm;
|
||||
|
|
@ -60,7 +60,7 @@ class PassphraseInfo {
|
|||
String algorithm;
|
||||
String salt;
|
||||
int iterations;
|
||||
int bits;
|
||||
int? bits;
|
||||
|
||||
PassphraseInfo();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// @dart=2.9
|
||||
|
||||
/* MIT License
|
||||
*
|
||||
* Copyright (C) 2019, 2020, 2021 Famedly GmbH
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// @dart=2.9
|
||||
|
||||
/* MIT License
|
||||
*
|
||||
* Copyright (C) 2019, 2020, 2021 Famedly GmbH
|
||||
|
|
@ -25,9 +25,9 @@
|
|||
import 'matrix_event.dart';
|
||||
|
||||
class EventsSyncUpdate {
|
||||
String start;
|
||||
String end;
|
||||
List<MatrixEvent> chunk;
|
||||
String? start;
|
||||
String? end;
|
||||
List<MatrixEvent>? chunk;
|
||||
|
||||
EventsSyncUpdate.fromJson(Map<String, dynamic> json)
|
||||
: start = json['start'],
|
||||
|
|
@ -47,7 +47,7 @@ class EventsSyncUpdate {
|
|||
data['end'] = end;
|
||||
}
|
||||
if (chunk != null) {
|
||||
data['chunk'] = chunk.map((i) => i.toJson()).toList();
|
||||
data['chunk'] = chunk!.map((i) => i.toJson()).toList();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// @dart=2.9
|
||||
|
||||
/* MIT License
|
||||
*
|
||||
* Copyright (C) 2019, 2020, 2021 Famedly GmbH
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// @dart=2.9
|
||||
|
||||
/* MIT License
|
||||
*
|
||||
* Copyright (C) 2019, 2020, 2021 Famedly GmbH
|
||||
|
|
@ -27,11 +27,11 @@ import '../utils/map_copy_extension.dart';
|
|||
|
||||
class MatrixEvent extends StrippedStateEvent {
|
||||
String eventId;
|
||||
String roomId;
|
||||
DateTime originServerTs;
|
||||
Map<String, dynamic> unsigned;
|
||||
Map<String, dynamic> prevContent;
|
||||
String redacts;
|
||||
String? roomId;
|
||||
late DateTime originServerTs;
|
||||
Map<String, dynamic>? unsigned;
|
||||
Map<String, dynamic>? prevContent;
|
||||
String? redacts;
|
||||
|
||||
MatrixEvent();
|
||||
|
||||
|
|
@ -40,8 +40,8 @@ class MatrixEvent extends StrippedStateEvent {
|
|||
roomId = json['room_id'],
|
||||
originServerTs =
|
||||
DateTime.fromMillisecondsSinceEpoch(json['origin_server_ts']),
|
||||
unsigned = (json['unsigned'] as Map<String, dynamic>)?.copy(),
|
||||
prevContent = (json['prev_content'] as Map<String, dynamic>)?.copy(),
|
||||
unsigned = (json['unsigned'] as Map<String, dynamic>?)?.copy(),
|
||||
prevContent = (json['prev_content'] as Map<String, dynamic>?)?.copy(),
|
||||
redacts = json['redacts'],
|
||||
super.fromJson(json);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// @dart=2.9
|
||||
|
||||
/* MIT License
|
||||
*
|
||||
* Copyright (C) 2019, 2020, 2021 Famedly GmbH
|
||||
|
|
@ -60,9 +60,9 @@ class MatrixException implements Exception {
|
|||
: 'Unknown error');
|
||||
|
||||
/// The frozen request which triggered this Error
|
||||
http.Response response;
|
||||
http.Response? response;
|
||||
|
||||
MatrixException(this.response) : raw = json.decode(response.body);
|
||||
MatrixException(Response this.response) : raw = json.decode(response.body);
|
||||
MatrixException.fromJson(Map<String, dynamic> content) : raw = content;
|
||||
|
||||
@override
|
||||
|
|
@ -73,21 +73,21 @@ class MatrixException implements Exception {
|
|||
(e) => e.toString() == 'MatrixError.${(raw["errcode"] ?? "")}',
|
||||
orElse: () => MatrixError.M_UNKNOWN);
|
||||
|
||||
int get retryAfterMs => raw['retry_after_ms'];
|
||||
int? get retryAfterMs => raw['retry_after_ms'];
|
||||
|
||||
/// This is a session identifier that the client must pass back to the homeserver, if one is provided,
|
||||
/// in subsequent attempts to authenticate in the same API call.
|
||||
String get session => raw['session'];
|
||||
String? get session => raw['session'];
|
||||
|
||||
/// Returns true if the server requires additional authentication.
|
||||
bool get requireAdditionalAuthentication => response != null
|
||||
? response.statusCode == 401
|
||||
? response!.statusCode == 401
|
||||
: authenticationFlows != null;
|
||||
|
||||
/// For each endpoint, a server offers one or more 'flows' that the client can use
|
||||
/// to authenticate itself. Each flow comprises a series of stages. If this request
|
||||
/// doesn't need additional authentication, then this is null.
|
||||
List<AuthenticationFlow> get authenticationFlows {
|
||||
List<AuthenticationFlow>?/*?*/ get authenticationFlows {
|
||||
if (!raw.containsKey('flows') || !(raw['flows'] is List)) return null;
|
||||
return (raw['flows'] as List)
|
||||
.map((flow) => flow['stages'])
|
||||
|
|
@ -99,7 +99,7 @@ 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['params'];
|
||||
Map<String, dynamic>? get authenticationParams => raw['params'];
|
||||
|
||||
/// Returns the list of already completed authentication flows from previous requests.
|
||||
List<String> get completedAuthenticationFlows =>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// @dart=2.9
|
||||
|
||||
/* MIT License
|
||||
*
|
||||
* Copyright (C) 2019, 2020, 2021 Famedly GmbH
|
||||
|
|
@ -26,16 +26,16 @@ import '../utils/map_copy_extension.dart';
|
|||
|
||||
class MatrixSignableKey {
|
||||
String userId;
|
||||
String identifier;
|
||||
String? identifier;
|
||||
Map<String, String> keys;
|
||||
Map<String, Map<String, String>> signatures;
|
||||
Map<String, dynamic> unsigned;
|
||||
Map<String, Map<String, String>>? signatures;
|
||||
Map<String, dynamic>? unsigned;
|
||||
|
||||
MatrixSignableKey(this.userId, this.identifier, 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, dynamic>? _json;
|
||||
|
||||
MatrixSignableKey.fromJson(Map<String, dynamic> json)
|
||||
: _json = json,
|
||||
|
|
@ -46,7 +46,7 @@ class MatrixSignableKey {
|
|||
? Map<String, Map<String, String>>.from((json['signatures'] as Map)
|
||||
.map((k, v) => MapEntry(k, Map<String, String>.from(v))))
|
||||
: null,
|
||||
unsigned = (json['unsigned'] as Map<String, dynamic>)?.copy();
|
||||
unsigned = (json['unsigned'] as Map<String, dynamic>?)?.copy();
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = _json ?? <String, dynamic>{};
|
||||
|
|
@ -65,14 +65,14 @@ class MatrixSignableKey {
|
|||
|
||||
class MatrixCrossSigningKey extends MatrixSignableKey {
|
||||
List<String> usage;
|
||||
String get publicKey => identifier;
|
||||
String? get publicKey => identifier;
|
||||
|
||||
MatrixCrossSigningKey(
|
||||
String userId,
|
||||
this.usage,
|
||||
Map<String, String> keys,
|
||||
Map<String, Map<String, String>> signatures, {
|
||||
Map<String, dynamic> unsigned,
|
||||
Map<String, dynamic>? unsigned,
|
||||
}) : super(userId, keys?.values?.first, keys, signatures, unsigned: unsigned);
|
||||
|
||||
@override
|
||||
|
|
@ -91,10 +91,10 @@ class MatrixCrossSigningKey extends MatrixSignableKey {
|
|||
}
|
||||
|
||||
class MatrixDeviceKeys extends MatrixSignableKey {
|
||||
String get deviceId => identifier;
|
||||
String get deviceId => identifier!;
|
||||
List<String> algorithms;
|
||||
String get deviceDisplayName =>
|
||||
unsigned != null ? unsigned['device_display_name'] : null;
|
||||
String? get deviceDisplayName =>
|
||||
unsigned != null ? unsigned!['device_display_name'] : null;
|
||||
|
||||
MatrixDeviceKeys(
|
||||
String userId,
|
||||
|
|
@ -102,7 +102,7 @@ class MatrixDeviceKeys extends MatrixSignableKey {
|
|||
this.algorithms,
|
||||
Map<String, String> keys,
|
||||
Map<String, Map<String, String>> signatures, {
|
||||
Map<String, dynamic> unsigned,
|
||||
Map<String, dynamic>? unsigned,
|
||||
}) : super(userId, deviceId, keys, signatures, unsigned: unsigned);
|
||||
|
||||
@override
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// @dart=2.9
|
||||
|
||||
/* MIT License
|
||||
*
|
||||
* Copyright (C) 2019, 2020, 2021 Famedly GmbH
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// @dart=2.9
|
||||
|
||||
/* MIT License
|
||||
*
|
||||
* Copyright (C) 2019, 2020, 2021 Famedly GmbH
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// @dart=2.9
|
||||
|
||||
/* MIT License
|
||||
*
|
||||
* Copyright (C) 2019, 2020, 2021 Famedly GmbH
|
||||
|
|
@ -26,9 +26,9 @@ import '../generated/model.dart';
|
|||
|
||||
class PresenceContent {
|
||||
PresenceType presence;
|
||||
int lastActiveAgo;
|
||||
String statusMsg;
|
||||
bool currentlyActive;
|
||||
int? lastActiveAgo;
|
||||
String? statusMsg;
|
||||
bool? currentlyActive;
|
||||
|
||||
PresenceContent.fromJson(Map<String, dynamic> json)
|
||||
: presence = PresenceType.values.firstWhere(
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// @dart=2.9
|
||||
|
||||
/* MIT License
|
||||
*
|
||||
* Copyright (C) 2019, 2020, 2021 Famedly GmbH
|
||||
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
class RequestTokenResponse {
|
||||
String sid;
|
||||
String submitUrl;
|
||||
String? submitUrl;
|
||||
|
||||
RequestTokenResponse.fromJson(Map<String, dynamic> json)
|
||||
: sid = json['sid'],
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// @dart=2.9
|
||||
|
||||
abstract class RoomCreationTypes {
|
||||
static const String mSpace = 'm.space';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// @dart=2.9
|
||||
|
||||
/* MIT License
|
||||
*
|
||||
* Copyright (C) 2019, 2020, 2021 Famedly GmbH
|
||||
|
|
@ -29,10 +29,10 @@ class RoomKeysSingleKey {
|
|||
Map<String, dynamic> sessionData;
|
||||
|
||||
RoomKeysSingleKey(
|
||||
{this.firstMessageIndex,
|
||||
this.forwardedCount,
|
||||
this.isVerified,
|
||||
this.sessionData});
|
||||
{required this.firstMessageIndex,
|
||||
required this.forwardedCount,
|
||||
required this.isVerified,
|
||||
required this.sessionData});
|
||||
|
||||
RoomKeysSingleKey.fromJson(Map<String, dynamic> json)
|
||||
: firstMessageIndex = json['first_message_index'],
|
||||
|
|
@ -53,7 +53,7 @@ class RoomKeysSingleKey {
|
|||
class RoomKeysRoom {
|
||||
Map<String, RoomKeysSingleKey> sessions;
|
||||
|
||||
RoomKeysRoom({this.sessions}) {
|
||||
RoomKeysRoom({required this.sessions}) {
|
||||
sessions ??= <String, RoomKeysSingleKey>{};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// @dart=2.9
|
||||
|
||||
/* MIT License
|
||||
*
|
||||
* Copyright (C) 2019, 2020, 2021 Famedly GmbH
|
||||
|
|
@ -23,9 +23,9 @@
|
|||
*/
|
||||
|
||||
class RoomSummary {
|
||||
List<String> mHeroes;
|
||||
int mJoinedMemberCount;
|
||||
int mInvitedMemberCount;
|
||||
List<String>? mHeroes;
|
||||
int? mJoinedMemberCount;
|
||||
int? mInvitedMemberCount;
|
||||
RoomSummary.fromJson(Map<String, dynamic> json)
|
||||
: mHeroes = json['m.heroes'] != null
|
||||
? List<String>.from(json['m.heroes'])
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// @dart=2.9
|
||||
|
||||
/* MIT License
|
||||
*
|
||||
* Copyright (C) 2019, 2020, 2021 Famedly GmbH
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// @dart=2.9
|
||||
|
||||
/* MIT License
|
||||
*
|
||||
* Copyright (C) 2019, 2020, 2021 Famedly GmbH
|
||||
|
|
@ -25,7 +25,7 @@
|
|||
import 'basic_event_with_sender.dart';
|
||||
|
||||
class StrippedStateEvent extends BasicEventWithSender {
|
||||
String stateKey;
|
||||
String? stateKey;
|
||||
|
||||
StrippedStateEvent();
|
||||
StrippedStateEvent.fromJson(Map<String, dynamic> json)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// @dart=2.9
|
||||
|
||||
/* MIT License
|
||||
*
|
||||
* Copyright (C) 2019, 2020, 2021 Famedly GmbH
|
||||
|
|
@ -72,7 +72,7 @@ class ProtocolFieldType {
|
|||
class ProtocolInstance {
|
||||
String networkId;
|
||||
String desc;
|
||||
String icon;
|
||||
String? icon;
|
||||
dynamic fields;
|
||||
|
||||
ProtocolInstance.fromJson(Map<String, dynamic> json) {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// @dart=2.9
|
||||
|
||||
/* MIT License
|
||||
*
|
||||
* Copyright (C) 2019, 2020, 2021 Famedly GmbH
|
||||
|
|
@ -32,13 +32,13 @@ import 'stripped_state_event.dart';
|
|||
|
||||
class SyncUpdate {
|
||||
String nextBatch;
|
||||
RoomsUpdate rooms;
|
||||
List<Presence> presence;
|
||||
List<BasicEvent> accountData;
|
||||
List<BasicEventWithSender> toDevice;
|
||||
DeviceListsUpdate deviceLists;
|
||||
Map<String, int> deviceOneTimeKeysCount;
|
||||
List<String> deviceUnusedFallbackKeyTypes;
|
||||
RoomsUpdate? rooms;
|
||||
List<Presence>? presence;
|
||||
List<BasicEvent>? accountData;
|
||||
List<BasicEventWithSender>? toDevice;
|
||||
DeviceListsUpdate? deviceLists;
|
||||
Map<String, int>? deviceOneTimeKeysCount;
|
||||
List<String>? deviceUnusedFallbackKeyTypes;
|
||||
|
||||
SyncUpdate();
|
||||
|
||||
|
|
@ -83,25 +83,25 @@ class SyncUpdate {
|
|||
final data = <String, dynamic>{};
|
||||
data['next_batch'] = nextBatch;
|
||||
if (rooms != null) {
|
||||
data['rooms'] = rooms.toJson();
|
||||
data['rooms'] = rooms!.toJson();
|
||||
}
|
||||
if (presence != null) {
|
||||
data['presence'] = {
|
||||
'events': presence.map((i) => i.toJson()).toList(),
|
||||
'events': presence!.map((i) => i.toJson()).toList(),
|
||||
};
|
||||
}
|
||||
if (accountData != null) {
|
||||
data['account_data'] = {
|
||||
'events': accountData.map((i) => i.toJson()).toList(),
|
||||
'events': accountData!.map((i) => i.toJson()).toList(),
|
||||
};
|
||||
}
|
||||
if (toDevice != null) {
|
||||
data['to_device'] = {
|
||||
'events': toDevice.map((i) => i.toJson()).toList(),
|
||||
'events': toDevice!.map((i) => i.toJson()).toList(),
|
||||
};
|
||||
}
|
||||
if (deviceLists != null) {
|
||||
data['device_lists'] = deviceLists.toJson();
|
||||
data['device_lists'] = deviceLists!.toJson();
|
||||
}
|
||||
if (deviceOneTimeKeysCount != null) {
|
||||
data['device_one_time_keys_count'] = deviceOneTimeKeysCount;
|
||||
|
|
@ -116,9 +116,9 @@ class SyncUpdate {
|
|||
}
|
||||
|
||||
class RoomsUpdate {
|
||||
Map<String, JoinedRoomUpdate> join;
|
||||
Map<String, InvitedRoomUpdate> invite;
|
||||
Map<String, LeftRoomUpdate> leave;
|
||||
Map<String, JoinedRoomUpdate>? join;
|
||||
Map<String, InvitedRoomUpdate>? invite;
|
||||
Map<String, LeftRoomUpdate>? leave;
|
||||
|
||||
RoomsUpdate();
|
||||
|
||||
|
|
@ -139,13 +139,13 @@ class RoomsUpdate {
|
|||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
if (join != null) {
|
||||
data['join'] = join.map((k, v) => MapEntry(k, v.toJson()));
|
||||
data['join'] = join!.map((k, v) => MapEntry(k, v.toJson()));
|
||||
}
|
||||
if (invite != null) {
|
||||
data['invite'] = invite.map((k, v) => MapEntry(k, v.toJson()));
|
||||
data['invite'] = invite!.map((k, v) => MapEntry(k, v.toJson()));
|
||||
}
|
||||
if (leave != null) {
|
||||
data['leave'] = leave.map((k, v) => MapEntry(k, v.toJson()));
|
||||
data['leave'] = leave!.map((k, v) => MapEntry(k, v.toJson()));
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
|
@ -154,12 +154,12 @@ class RoomsUpdate {
|
|||
abstract class SyncRoomUpdate {}
|
||||
|
||||
class JoinedRoomUpdate extends SyncRoomUpdate {
|
||||
RoomSummary summary;
|
||||
List<MatrixEvent> state;
|
||||
TimelineUpdate timeline;
|
||||
List<BasicRoomEvent> ephemeral;
|
||||
List<BasicRoomEvent> accountData;
|
||||
UnreadNotificationCounts unreadNotifications;
|
||||
RoomSummary? summary;
|
||||
List<MatrixEvent>? state;
|
||||
TimelineUpdate? timeline;
|
||||
List<BasicRoomEvent>? ephemeral;
|
||||
List<BasicRoomEvent>? accountData;
|
||||
UnreadNotificationCounts? unreadNotifications;
|
||||
|
||||
JoinedRoomUpdate();
|
||||
|
||||
|
|
@ -195,35 +195,35 @@ class JoinedRoomUpdate extends SyncRoomUpdate {
|
|||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
if (summary != null) {
|
||||
data['summary'] = summary.toJson();
|
||||
data['summary'] = summary!.toJson();
|
||||
}
|
||||
if (state != null) {
|
||||
data['state'] = {
|
||||
'events': state.map((i) => i.toJson()).toList(),
|
||||
'events': state!.map((i) => i.toJson()).toList(),
|
||||
};
|
||||
}
|
||||
if (timeline != null) {
|
||||
data['timeline'] = timeline.toJson();
|
||||
data['timeline'] = timeline!.toJson();
|
||||
}
|
||||
if (ephemeral != null) {
|
||||
data['ephemeral'] = {
|
||||
'events': ephemeral.map((i) => i.toJson()).toList(),
|
||||
'events': ephemeral!.map((i) => i.toJson()).toList(),
|
||||
};
|
||||
}
|
||||
if (accountData != null) {
|
||||
data['account_data'] = {
|
||||
'events': accountData.map((i) => i.toJson()).toList(),
|
||||
'events': accountData!.map((i) => i.toJson()).toList(),
|
||||
};
|
||||
}
|
||||
if (unreadNotifications != null) {
|
||||
data['unread_notifications'] = unreadNotifications.toJson();
|
||||
data['unread_notifications'] = unreadNotifications!.toJson();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class InvitedRoomUpdate extends SyncRoomUpdate {
|
||||
List<StrippedStateEvent> inviteState;
|
||||
List<StrippedStateEvent>? inviteState;
|
||||
InvitedRoomUpdate.fromJson(Map<String, dynamic> json) {
|
||||
inviteState =
|
||||
(json['invite_state'] != null && json['invite_state']['events'] != null)
|
||||
|
|
@ -236,7 +236,7 @@ class InvitedRoomUpdate extends SyncRoomUpdate {
|
|||
final data = <String, dynamic>{};
|
||||
if (inviteState != null) {
|
||||
data['invite_state'] = {
|
||||
'events': inviteState.map((i) => i.toJson()).toList(),
|
||||
'events': inviteState!.map((i) => i.toJson()).toList(),
|
||||
};
|
||||
}
|
||||
return data;
|
||||
|
|
@ -244,9 +244,9 @@ class InvitedRoomUpdate extends SyncRoomUpdate {
|
|||
}
|
||||
|
||||
class LeftRoomUpdate extends SyncRoomUpdate {
|
||||
List<MatrixEvent> state;
|
||||
TimelineUpdate timeline;
|
||||
List<BasicRoomEvent> accountData;
|
||||
List<MatrixEvent>? state;
|
||||
TimelineUpdate? timeline;
|
||||
List<BasicRoomEvent>? accountData;
|
||||
|
||||
LeftRoomUpdate();
|
||||
|
||||
|
|
@ -270,15 +270,15 @@ class LeftRoomUpdate extends SyncRoomUpdate {
|
|||
final data = <String, dynamic>{};
|
||||
if (state != null) {
|
||||
data['state'] = {
|
||||
'events': state.map((i) => i.toJson()).toList(),
|
||||
'events': state!.map((i) => i.toJson()).toList(),
|
||||
};
|
||||
}
|
||||
if (timeline != null) {
|
||||
data['timeline'] = timeline.toJson();
|
||||
data['timeline'] = timeline!.toJson();
|
||||
}
|
||||
if (accountData != null) {
|
||||
data['account_data'] = {
|
||||
'events': accountData.map((i) => i.toJson()).toList(),
|
||||
'events': accountData!.map((i) => i.toJson()).toList(),
|
||||
};
|
||||
}
|
||||
return data;
|
||||
|
|
@ -286,9 +286,9 @@ class LeftRoomUpdate extends SyncRoomUpdate {
|
|||
}
|
||||
|
||||
class TimelineUpdate {
|
||||
List<MatrixEvent> events;
|
||||
bool limited;
|
||||
String prevBatch;
|
||||
List<MatrixEvent>? events;
|
||||
bool? limited;
|
||||
String? prevBatch;
|
||||
|
||||
TimelineUpdate();
|
||||
|
||||
|
|
@ -303,7 +303,7 @@ class TimelineUpdate {
|
|||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
if (events != null) {
|
||||
data['events'] = events.map((i) => i.toJson()).toList();
|
||||
data['events'] = events!.map((i) => i.toJson()).toList();
|
||||
}
|
||||
if (limited != null) {
|
||||
data['limited'] = limited;
|
||||
|
|
@ -316,8 +316,8 @@ class TimelineUpdate {
|
|||
}
|
||||
|
||||
class UnreadNotificationCounts {
|
||||
int highlightCount;
|
||||
int notificationCount;
|
||||
int? highlightCount;
|
||||
int? notificationCount;
|
||||
UnreadNotificationCounts.fromJson(Map<String, dynamic> json) {
|
||||
highlightCount = json['highlight_count'];
|
||||
notificationCount = json['notification_count'];
|
||||
|
|
@ -335,8 +335,8 @@ class UnreadNotificationCounts {
|
|||
}
|
||||
|
||||
class DeviceListsUpdate {
|
||||
List<String> changed;
|
||||
List<String> left;
|
||||
List<String>? changed;
|
||||
List<String>? left;
|
||||
DeviceListsUpdate.fromJson(Map<String, dynamic> json) {
|
||||
changed = List<String>.from(json['changed'] ?? []);
|
||||
left = List<String>.from(json['left'] ?? []);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// @dart=2.9
|
||||
|
||||
/* MIT License
|
||||
*
|
||||
* Copyright (C) 2019, 2020, 2021 Famedly GmbH
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// @dart=2.9
|
||||
|
||||
/* MIT License
|
||||
*
|
||||
* Copyright (C) 2019, 2020, 2021 Famedly GmbH
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// @dart=2.9
|
||||
|
||||
/* MIT License
|
||||
*
|
||||
* Copyright (C) 2019, 2020, 2021 Famedly GmbH
|
||||
|
|
@ -25,7 +25,7 @@
|
|||
import 'matrix_exception.dart';
|
||||
|
||||
class UploadKeySignaturesResponse {
|
||||
Map<String, Map<String, MatrixException>> failures;
|
||||
Map<String, Map<String, MatrixException>>? failures;
|
||||
|
||||
UploadKeySignaturesResponse.fromJson(Map<String, dynamic> json)
|
||||
: failures = json['failures'] != null
|
||||
|
|
@ -43,7 +43,7 @@ class UploadKeySignaturesResponse {
|
|||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
if (failures != null) {
|
||||
data['failures'] = failures.map(
|
||||
data['failures'] = failures!.map(
|
||||
(k, v) => MapEntry(
|
||||
k,
|
||||
v.map(
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// @dart=2.9
|
||||
|
||||
/* MIT License
|
||||
*
|
||||
* Copyright (C) 2019, 2020, 2021 Famedly GmbH
|
||||
|
|
@ -51,7 +51,7 @@ class Logs {
|
|||
}
|
||||
}
|
||||
|
||||
void wtf(String title, [Object exception, StackTrace stackTrace]) =>
|
||||
void wtf(String title, [Object? exception, StackTrace? stackTrace]) =>
|
||||
addLogEvent(
|
||||
LogEvent(
|
||||
title,
|
||||
|
|
@ -61,7 +61,7 @@ class Logs {
|
|||
),
|
||||
);
|
||||
|
||||
void e(String title, [Object exception, StackTrace stackTrace]) =>
|
||||
void e(String title, [Object? exception, StackTrace? stackTrace]) =>
|
||||
addLogEvent(
|
||||
LogEvent(
|
||||
title,
|
||||
|
|
@ -71,7 +71,7 @@ class Logs {
|
|||
),
|
||||
);
|
||||
|
||||
void w(String title, [Object exception, StackTrace stackTrace]) =>
|
||||
void w(String title, [Object? exception, StackTrace? stackTrace]) =>
|
||||
addLogEvent(
|
||||
LogEvent(
|
||||
title,
|
||||
|
|
@ -81,7 +81,7 @@ class Logs {
|
|||
),
|
||||
);
|
||||
|
||||
void i(String title, [Object exception, StackTrace stackTrace]) =>
|
||||
void i(String title, [Object? exception, StackTrace? stackTrace]) =>
|
||||
addLogEvent(
|
||||
LogEvent(
|
||||
title,
|
||||
|
|
@ -91,7 +91,7 @@ class Logs {
|
|||
),
|
||||
);
|
||||
|
||||
void d(String title, [Object exception, StackTrace stackTrace]) =>
|
||||
void d(String title, [Object? exception, StackTrace? stackTrace]) =>
|
||||
addLogEvent(
|
||||
LogEvent(
|
||||
title,
|
||||
|
|
@ -101,7 +101,7 @@ class Logs {
|
|||
),
|
||||
);
|
||||
|
||||
void v(String title, [Object exception, StackTrace stackTrace]) =>
|
||||
void v(String title, [Object? exception, StackTrace? stackTrace]) =>
|
||||
addLogEvent(
|
||||
LogEvent(
|
||||
title,
|
||||
|
|
@ -115,8 +115,8 @@ class Logs {
|
|||
// ignore: avoid_print
|
||||
class LogEvent {
|
||||
final String title;
|
||||
final Object exception;
|
||||
final StackTrace stackTrace;
|
||||
final Object? exception;
|
||||
final StackTrace? stackTrace;
|
||||
final Level level;
|
||||
|
||||
LogEvent(
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// @dart=2.9
|
||||
|
||||
/* MIT License
|
||||
*
|
||||
* Copyright (C) 2019, 2020, 2021 Famedly GmbH
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// @dart=2.9
|
||||
|
||||
/* MIT License
|
||||
*
|
||||
* Copyright (C) 2019, 2020, 2021 Famedly GmbH
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// @dart=2.9
|
||||
|
||||
/* MIT License
|
||||
*
|
||||
* Copyright (C) 2019, 2020, 2021 Famedly GmbH
|
||||
|
|
@ -29,7 +29,7 @@ import 'dart:convert';
|
|||
void main() {
|
||||
group('Event Content tests', () {
|
||||
test('Room Encryption Content', () {
|
||||
var json = <String, dynamic>{
|
||||
Map<String, dynamic>? json = <String, dynamic>{
|
||||
'content': {
|
||||
'algorithm': 'm.megolm.v1.aes-sha2',
|
||||
'rotation_period_ms': 604800000,
|
||||
|
|
@ -44,11 +44,11 @@ void main() {
|
|||
'unsigned': {'age': 1234}
|
||||
};
|
||||
json = jsonDecode(jsonEncode(json));
|
||||
expect(MatrixEvent.fromJson(json).parsedRoomEncryptionContent.toJson(),
|
||||
expect(MatrixEvent.fromJson(json!).parsedRoomEncryptionContent.toJson(),
|
||||
json['content']);
|
||||
});
|
||||
test('Room Encrypted Content', () {
|
||||
var json = <String, dynamic>{
|
||||
Map<String, dynamic>? json = <String, dynamic>{
|
||||
'content': {
|
||||
'algorithm': 'm.megolm.v1.aes-sha2',
|
||||
'ciphertext': 'AwgAEnACgAkLmt6qF84IK++J7UDH2Za1YVchHyprqTqsg...',
|
||||
|
|
@ -64,7 +64,7 @@ void main() {
|
|||
'unsigned': {'age': 1234}
|
||||
};
|
||||
json = jsonDecode(jsonEncode(json));
|
||||
expect(MatrixEvent.fromJson(json).parsedRoomEncryptedContent.toJson(),
|
||||
expect(MatrixEvent.fromJson(json!).parsedRoomEncryptedContent.toJson(),
|
||||
json['content']);
|
||||
json = <String, dynamic>{
|
||||
'content': {
|
||||
|
|
@ -85,11 +85,11 @@ void main() {
|
|||
'unsigned': {'age': 1234}
|
||||
};
|
||||
json = jsonDecode(jsonEncode(json));
|
||||
expect(MatrixEvent.fromJson(json).parsedRoomEncryptedContent.toJson(),
|
||||
expect(MatrixEvent.fromJson(json!).parsedRoomEncryptedContent.toJson(),
|
||||
json['content']);
|
||||
});
|
||||
test('Room Key Content', () {
|
||||
var json = <String, dynamic>{
|
||||
Map<String, dynamic>? json = <String, dynamic>{
|
||||
'content': {
|
||||
'algorithm': 'm.megolm.v1.aes-sha2',
|
||||
'room_id': '!Cuyf34gef24t:localhost',
|
||||
|
|
@ -99,11 +99,11 @@ void main() {
|
|||
'type': 'm.room_key'
|
||||
};
|
||||
json = jsonDecode(jsonEncode(json));
|
||||
expect(BasicEvent.fromJson(json).parsedRoomKeyContent.toJson(),
|
||||
expect(BasicEvent.fromJson(json!).parsedRoomKeyContent.toJson(),
|
||||
json['content']);
|
||||
});
|
||||
test('Room Key Request Content', () {
|
||||
var json = <String, dynamic>{
|
||||
Map<String, dynamic>? json = <String, dynamic>{
|
||||
'content': {
|
||||
'action': 'request_cancellation',
|
||||
'request_id': '1495474790150.19',
|
||||
|
|
@ -112,7 +112,7 @@ void main() {
|
|||
'type': 'm.room_key_request'
|
||||
};
|
||||
json = jsonDecode(jsonEncode(json));
|
||||
expect(BasicEvent.fromJson(json).parsedRoomKeyRequestContent.toJson(),
|
||||
expect(BasicEvent.fromJson(json!).parsedRoomKeyRequestContent.toJson(),
|
||||
json['content']);
|
||||
json = <String, dynamic>{
|
||||
'content': {
|
||||
|
|
@ -129,11 +129,11 @@ void main() {
|
|||
'type': 'm.room_key_request'
|
||||
};
|
||||
json = jsonDecode(jsonEncode(json));
|
||||
expect(BasicEvent.fromJson(json).parsedRoomKeyRequestContent.toJson(),
|
||||
expect(BasicEvent.fromJson(json!).parsedRoomKeyRequestContent.toJson(),
|
||||
json['content']);
|
||||
});
|
||||
test('Forwarded Room Key Content', () {
|
||||
var json = <String, dynamic>{
|
||||
Map<String, dynamic>? json = <String, dynamic>{
|
||||
'content': {
|
||||
'algorithm': 'm.megolm.v1.aes-sha2',
|
||||
'forwarding_curve25519_key_chain': [
|
||||
|
|
@ -149,11 +149,11 @@ void main() {
|
|||
'type': 'm.forwarded_room_key'
|
||||
};
|
||||
json = jsonDecode(jsonEncode(json));
|
||||
expect(BasicEvent.fromJson(json).parsedForwardedRoomKeyContent.toJson(),
|
||||
expect(BasicEvent.fromJson(json!).parsedForwardedRoomKeyContent.toJson(),
|
||||
json['content']);
|
||||
});
|
||||
test('OLM Plaintext Payload', () {
|
||||
var json = <String, dynamic>{
|
||||
Map<String, dynamic>? json = <String, dynamic>{
|
||||
'type': '<type of the plaintext event>',
|
||||
'content': <String, dynamic>{
|
||||
'msgtype': 'm.text',
|
||||
|
|
@ -165,7 +165,7 @@ void main() {
|
|||
'keys': {'ed25519': '<sender_ed25519_key>'}
|
||||
};
|
||||
json = jsonDecode(jsonEncode(json));
|
||||
expect(OlmPlaintextPayload.fromJson(json).toJson(), json);
|
||||
expect(OlmPlaintextPayload.fromJson(json!).toJson(), json);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// @dart=2.9
|
||||
|
||||
/* MIT License
|
||||
*
|
||||
* Copyright (C) 2019, 2020, 2021 Famedly GmbH
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// @dart=2.9
|
||||
|
||||
/* MIT License
|
||||
*
|
||||
* Copyright (C) 2019, 2020, 2021 Famedly GmbH
|
||||
|
|
@ -61,8 +61,8 @@ void main() {
|
|||
'completed': ['example.type.foo']
|
||||
});
|
||||
expect(
|
||||
exception.authenticationFlows.first.stages.first, 'example.type.foo');
|
||||
expect(exception.authenticationParams['example.type.baz'],
|
||||
exception.authenticationFlows!.first.stages.first, 'example.type.foo');
|
||||
expect(exception.authenticationParams!['example.type.baz'],
|
||||
{'example_key': 'foobar'});
|
||||
expect(exception.session, 'xxxxxxyz');
|
||||
expect(exception.completedAuthenticationFlows, ['example.type.foo']);
|
||||
|
|
@ -109,12 +109,12 @@ void main() {
|
|||
} catch (exception) {
|
||||
expect(exception is MatrixException, true);
|
||||
expect((exception as MatrixException).errcode, 'M_FORBIDDEN');
|
||||
expect((exception as MatrixException).error, MatrixError.M_FORBIDDEN);
|
||||
expect((exception as MatrixException).errorMessage, 'Blabla');
|
||||
expect((exception as MatrixException).requireAdditionalAuthentication,
|
||||
expect(exception.error, MatrixError.M_FORBIDDEN);
|
||||
expect(exception.errorMessage, 'Blabla');
|
||||
expect(exception.requireAdditionalAuthentication,
|
||||
false);
|
||||
expect(
|
||||
(exception as MatrixException).toString(), 'M_FORBIDDEN: Blabla');
|
||||
exception.toString(), 'M_FORBIDDEN: Blabla');
|
||||
error = true;
|
||||
}
|
||||
expect(error, true);
|
||||
|
|
@ -124,8 +124,8 @@ void main() {
|
|||
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
|
||||
final supportedVersions = await matrixApi.getVersions();
|
||||
expect(supportedVersions.versions.contains('r0.5.0'), true);
|
||||
expect(supportedVersions.unstableFeatures['m.lazy_load_members'], true);
|
||||
expect(FakeMatrixApi.api['GET']['/client/versions']({}),
|
||||
expect(supportedVersions.unstableFeatures!['m.lazy_load_members'], true);
|
||||
expect(FakeMatrixApi.api['GET'],
|
||||
supportedVersions.toJson());
|
||||
matrixApi.homeserver = null;
|
||||
});
|
||||
|
|
@ -146,9 +146,9 @@ void main() {
|
|||
});
|
||||
test('getLoginTypes', () async {
|
||||
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
|
||||
final loginTypes = await matrixApi.getLoginFlows();
|
||||
final loginTypes = await (matrixApi.getLoginFlows() as FutureOr<List<LoginFlow>>);
|
||||
expect(loginTypes.first.type, 'm.login.password');
|
||||
expect(FakeMatrixApi.api['GET']['/client/r0/login']({}),
|
||||
expect(FakeMatrixApi.api['GET'],
|
||||
{'flows': loginTypes.map((x) => x.toJson()).toList()});
|
||||
matrixApi.homeserver = null;
|
||||
});
|
||||
|
|
@ -158,7 +158,7 @@ void main() {
|
|||
LoginType.mLoginPassword,
|
||||
identifier: AuthenticationUserIdentifier(user: 'username'),
|
||||
);
|
||||
expect(FakeMatrixApi.api['POST']['/client/r0/login']({}),
|
||||
expect(FakeMatrixApi.api['POST'],
|
||||
loginResponse.toJson());
|
||||
matrixApi.homeserver = null;
|
||||
});
|
||||
|
|
@ -178,7 +178,7 @@ void main() {
|
|||
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
|
||||
final registerResponse =
|
||||
await matrixApi.register(kind: AccountKind.guest, username: 'test');
|
||||
expect(FakeMatrixApi.api['POST']['/client/r0/register?kind=guest']({}),
|
||||
expect(FakeMatrixApi.api['POST'],
|
||||
registerResponse.toJson());
|
||||
matrixApi.homeserver = null;
|
||||
});
|
||||
|
|
@ -194,7 +194,7 @@ void main() {
|
|||
idAccessToken: '1234',
|
||||
);
|
||||
expect(
|
||||
FakeMatrixApi.api['POST']
|
||||
FakeMatrixApi.api['POST']!
|
||||
['/client/r0/register/email/requestToken']({}),
|
||||
response.toJson());
|
||||
matrixApi.homeserver = matrixApi.accessToken = null;
|
||||
|
|
@ -212,7 +212,7 @@ void main() {
|
|||
idAccessToken: '1234',
|
||||
);
|
||||
expect(
|
||||
FakeMatrixApi.api['POST']
|
||||
FakeMatrixApi.api['POST']!
|
||||
['/client/r0/register/email/requestToken']({}),
|
||||
response.toJson());
|
||||
matrixApi.homeserver = matrixApi.accessToken = null;
|
||||
|
|
@ -281,8 +281,8 @@ void main() {
|
|||
test('getThirdPartyIdentifiers', () async {
|
||||
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
|
||||
matrixApi.accessToken = '1234';
|
||||
final response = await matrixApi.getAccount3PIDs();
|
||||
expect(FakeMatrixApi.api['GET']['/client/r0/account/3pid']({}),
|
||||
final response = await (matrixApi.getAccount3PIDs() as FutureOr<List<ThirdPartyIdentifier>>);
|
||||
expect(FakeMatrixApi.api['GET'],
|
||||
{'threepids': response.map((t) => t.toJson()).toList()});
|
||||
matrixApi.homeserver = matrixApi.accessToken = null;
|
||||
});
|
||||
|
|
@ -364,7 +364,7 @@ void main() {
|
|||
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
|
||||
matrixApi.accessToken = '1234';
|
||||
final response = await matrixApi.getCapabilities();
|
||||
expect(FakeMatrixApi.api['GET']['/client/r0/capabilities']({}),
|
||||
expect(FakeMatrixApi.api['GET'],
|
||||
{'capabilities': response.toJson()});
|
||||
matrixApi.homeserver = matrixApi.accessToken = null;
|
||||
});
|
||||
|
|
@ -498,9 +498,9 @@ void main() {
|
|||
timeout: 15,
|
||||
);
|
||||
expect(
|
||||
FakeMatrixApi.api['GET'][
|
||||
FakeMatrixApi.api['GET'] as Map,
|
||||
{}) as Map?,
|
||||
response.toJson());
|
||||
matrixApi.homeserver = matrixApi.accessToken = null;
|
||||
});
|
||||
|
|
@ -537,12 +537,12 @@ void main() {
|
|||
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
|
||||
matrixApi.accessToken = '1234';
|
||||
|
||||
final states = await matrixApi.getMembersByRoom(
|
||||
final states = await (matrixApi.getMembersByRoom(
|
||||
'!localpart:server.abc',
|
||||
at: '1234',
|
||||
membership: Membership.join,
|
||||
notMembership: Membership.leave,
|
||||
);
|
||||
) as FutureOr<List<MatrixEvent>>);
|
||||
expect(states.length, 1);
|
||||
|
||||
matrixApi.homeserver = matrixApi.accessToken = null;
|
||||
|
|
@ -551,11 +551,11 @@ void main() {
|
|||
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
|
||||
matrixApi.accessToken = '1234';
|
||||
|
||||
final states = await matrixApi.getJoinedMembersByRoom(
|
||||
final states = await (matrixApi.getJoinedMembersByRoom(
|
||||
'!localpart:server.abc',
|
||||
);
|
||||
) as FutureOr<Map<String, RoomMember>>);
|
||||
expect(states.length, 1);
|
||||
expect(states['@bar:example.com'].toJson(), {
|
||||
expect(states['@bar:example.com']!.toJson(), {
|
||||
'display_name': 'Bar',
|
||||
'avatar_url': 'mxc://riot.ovh/printErCATzZijQsSDWorRaK'
|
||||
});
|
||||
|
|
@ -576,9 +576,9 @@ void main() {
|
|||
);
|
||||
|
||||
expect(
|
||||
FakeMatrixApi.api['GET'][
|
||||
FakeMatrixApi.api['GET'] as Map,
|
||||
{}) as Map?,
|
||||
timelineHistoryResponse.toJson());
|
||||
|
||||
matrixApi.homeserver = matrixApi.accessToken = null;
|
||||
|
|
@ -667,7 +667,7 @@ void main() {
|
|||
);
|
||||
|
||||
expect(
|
||||
FakeMatrixApi.api['GET']
|
||||
FakeMatrixApi.api['GET']!
|
||||
['/client/r0/directory/room/%23testalias%3Aexample.com']({}),
|
||||
roomAliasInformation.toJson());
|
||||
|
||||
|
|
@ -829,7 +829,7 @@ void main() {
|
|||
);
|
||||
|
||||
expect(
|
||||
FakeMatrixApi.api['GET'][
|
||||
FakeMatrixApi.api['GET'],
|
||||
response.toJson());
|
||||
|
||||
|
|
@ -851,7 +851,7 @@ void main() {
|
|||
);
|
||||
|
||||
expect(
|
||||
FakeMatrixApi.api['POST']
|
||||
FakeMatrixApi.api['POST']!
|
||||
['/client/r0/publicRooms?server=example.com']({}),
|
||||
response.toJson());
|
||||
|
||||
|
|
@ -866,7 +866,7 @@ void main() {
|
|||
limit: 10,
|
||||
);
|
||||
|
||||
expect(FakeMatrixApi.api['POST']['/client/r0/user_directory/search']({}),
|
||||
expect(FakeMatrixApi.api['POST'],
|
||||
response.toJson());
|
||||
|
||||
matrixApi.homeserver = matrixApi.accessToken = null;
|
||||
|
|
@ -913,7 +913,7 @@ void main() {
|
|||
|
||||
final response = await matrixApi.getUserProfile('@alice:example.com');
|
||||
expect(
|
||||
FakeMatrixApi.api['GET']
|
||||
FakeMatrixApi.api['GET']!
|
||||
['/client/r0/profile/%40alice%3Aexample.com']({}),
|
||||
response.toJson());
|
||||
|
||||
|
|
@ -924,7 +924,7 @@ void main() {
|
|||
matrixApi.accessToken = '1234';
|
||||
|
||||
final response = await matrixApi.getTurnServer();
|
||||
expect(FakeMatrixApi.api['GET']['/client/r0/voip/turnServer']({}),
|
||||
expect(FakeMatrixApi.api['GET'],
|
||||
response.toJson());
|
||||
|
||||
matrixApi.homeserver = matrixApi.accessToken = null;
|
||||
|
|
@ -987,7 +987,7 @@ void main() {
|
|||
'@alice:example.com',
|
||||
);
|
||||
expect(
|
||||
FakeMatrixApi.api['GET'][
|
||||
FakeMatrixApi.api['GET'],
|
||||
response.toJson());
|
||||
|
||||
|
|
@ -1017,7 +1017,7 @@ void main() {
|
|||
ts: 10,
|
||||
);
|
||||
expect(
|
||||
FakeMatrixApi.api['GET']
|
||||
FakeMatrixApi.api['GET']!
|
||||
['/media/r0/preview_url?url=https%3A%2F%2Fmatrix.org&ts=10']({}),
|
||||
openGraphData.toJson());
|
||||
|
||||
|
|
@ -1048,8 +1048,8 @@ void main() {
|
|||
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
|
||||
matrixApi.accessToken = '1234';
|
||||
|
||||
final devices = await matrixApi.getDevices();
|
||||
expect(FakeMatrixApi.api['GET']['/client/r0/devices']({})['devices'],
|
||||
final devices = await (matrixApi.getDevices() as FutureOr<List<Device>>);
|
||||
expect(FakeMatrixApi.api['GET']['devices'],
|
||||
devices.map((i) => i.toJson()).toList());
|
||||
|
||||
matrixApi.homeserver = matrixApi.accessToken = null;
|
||||
|
|
@ -1118,10 +1118,10 @@ void main() {
|
|||
);
|
||||
expect(
|
||||
response
|
||||
.deviceKeys['@alice:example.com']['JLAFKJWSCS'].deviceDisplayName,
|
||||
.deviceKeys!['@alice:example.com']!['JLAFKJWSCS']!.deviceDisplayName,
|
||||
'Alices mobile phone');
|
||||
expect(
|
||||
FakeMatrixApi.api['POST']
|
||||
FakeMatrixApi.api['POST']!
|
||||
['/client/r0/keys/query']({'device_keys': {}}),
|
||||
response.toJson());
|
||||
|
||||
|
|
@ -1138,7 +1138,7 @@ void main() {
|
|||
timeout: 10,
|
||||
);
|
||||
expect(
|
||||
FakeMatrixApi.api['POST']['/client/r0/keys/claim']({
|
||||
FakeMatrixApi.api['POST'] {
|
|||
});
|
||||
final ret = await matrixApi.uploadKeySignatures([key1, key2]);
|
||||
expect(
|
||||
FakeMatrixApi.api['POST']['/client/r0/keys/signatures/upload']({}),
|
||||
FakeMatrixApi.api['POST'],
|
||||
ret.toJson(),
|
||||
);
|
||||
});
|
||||
|
|
@ -1242,9 +1242,9 @@ void main() {
|
|||
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
|
||||
matrixApi.accessToken = '1234';
|
||||
|
||||
final response = await matrixApi.getPushers();
|
||||
final response = await (matrixApi.getPushers() as FutureOr<List<Pusher>>);
|
||||
expect(
|
||||
FakeMatrixApi.api['GET']['/client/r0/pushers']({}),
|
||||
FakeMatrixApi.api['GET'],
|
||||
{'pushers': response.map((i) => i.toJson()).toList()},
|
||||
);
|
||||
|
||||
|
|
@ -1281,7 +1281,7 @@ void main() {
|
|||
only: '1234',
|
||||
);
|
||||
expect(
|
||||
FakeMatrixApi.api['GET']
|
||||
FakeMatrixApi.api['GET']!
|
||||
['/client/r0/notifications?from=1234&limit=10&only=1234']({}),
|
||||
response.toJson(),
|
||||
);
|
||||
|
|
@ -1294,7 +1294,7 @@ void main() {
|
|||
|
||||
final response = await matrixApi.getPushRules();
|
||||
expect(
|
||||
FakeMatrixApi.api['GET']['/client/r0/pushrules']({}),
|
||||
FakeMatrixApi.api['GET'],
|
||||
{'global': response.toJson()},
|
||||
);
|
||||
|
||||
|
|
@ -1307,7 +1307,7 @@ void main() {
|
|||
final response =
|
||||
await matrixApi.getPushRule('global', PushRuleKind.content, 'nocake');
|
||||
expect(
|
||||
FakeMatrixApi.api['GET']
|
||||
FakeMatrixApi.api['GET']!
|
||||
['/client/r0/pushrules/global/content/nocake']({}),
|
||||
response.toJson(),
|
||||
);
|
||||
|
|
@ -1407,7 +1407,7 @@ void main() {
|
|||
final response =
|
||||
await matrixApi.getEvents(from: '1234', roomId: '!1234', timeout: 10);
|
||||
expect(
|
||||
FakeMatrixApi.api['GET']
|
||||
FakeMatrixApi.api['GET']!
|
||||
['/client/r0/events?from=1234&timeout=10&roomId=%211234']({}),
|
||||
response.toJson(),
|
||||
);
|
||||
|
|
@ -1418,10 +1418,10 @@ void main() {
|
|||
matrixApi.homeserver = Uri.parse('https://fakeserver.notexisting');
|
||||
matrixApi.accessToken = '1234';
|
||||
|
||||
final response = await matrixApi.getRoomTags(
|
||||
'@alice:example.com', '!localpart:example.com');
|
||||
final response = await (matrixApi.getRoomTags(
|
||||
'@alice:example.com', '!localpart:example.com') as FutureOr<Map<String, Tag>>);
|
||||
expect(
|
||||
FakeMatrixApi.api['GET'][
|
||||
FakeMatrixApi.api['GET'],
|
||||
{'tags': response.map((k, v) => MapEntry(k, v.toJson()))},
|
||||
);
|
||||
|
|
@ -1507,7 +1507,7 @@ void main() {
|
|||
|
||||
final response = await matrixApi.getWhoIs('@alice:example.com');
|
||||
expect(
|
||||
FakeMatrixApi.api['GET']
|
||||
FakeMatrixApi.api['GET']!
|
||||
['/client/r0/admin/whois/%40alice%3Aexample.com']({}),
|
||||
response.toJson(),
|
||||
);
|
||||
|
|
@ -1521,7 +1521,7 @@ void main() {
|
|||
final response = await matrixApi.getEventContext('1234', '1234',
|
||||
limit: 10, filter: '{}');
|
||||
expect(
|
||||
FakeMatrixApi.api['GET']
|
||||
FakeMatrixApi.api['GET']!
|
||||
['/client/r0/rooms/1234/context/1234?limit=10&filter=%7B%7D']({}),
|
||||
response.toJson(),
|
||||
);
|
||||
|
|
@ -1547,7 +1547,7 @@ void main() {
|
|||
|
||||
final response = await matrixApi.requestSupportedProtocols();
|
||||
expect(
|
||||
FakeMatrixApi.api['GET']['/client/r0/thirdparty/protocols']({}),
|
||||
FakeMatrixApi.api['GET'],
|
||||
response.map((k, v) => MapEntry(k, v.toJson())),
|
||||
);
|
||||
|
||||
|
|
@ -1559,7 +1559,7 @@ void main() {
|
|||
|
||||
final response = await matrixApi.requestSupportedProtocol('irc');
|
||||
expect(
|
||||
FakeMatrixApi.api['GET']['/client/r0/thirdparty/protocol/irc']({}),
|
||||
FakeMatrixApi.api['GET'],
|
||||
response.toJson(),
|
||||
);
|
||||
|
||||
|
|
@ -1571,7 +1571,7 @@ void main() {
|
|||
|
||||
final response = await matrixApi.requestThirdPartyLocations('irc');
|
||||
expect(
|
||||
FakeMatrixApi.api['GET']['/client/r0/thirdparty/location/irc']({}),
|
||||
FakeMatrixApi.api['GET'],
|
||||
response.map((i) => i.toJson()).toList(),
|
||||
);
|
||||
|
||||
|
|
@ -1583,7 +1583,7 @@ void main() {
|
|||
|
||||
final response = await matrixApi.requestThirdPartyUsers('irc');
|
||||
expect(
|
||||
FakeMatrixApi.api['GET']['/client/r0/thirdparty/user/irc']({}),
|
||||
FakeMatrixApi.api['GET'],
|
||||
response.map((i) => i.toJson()).toList(),
|
||||
);
|
||||
|
||||
|
|
@ -1596,7 +1596,7 @@ void main() {
|
|||
final response =
|
||||
await matrixApi.requestThirdPartyLocationsByAlias('1234');
|
||||
expect(
|
||||
FakeMatrixApi.api['GET']
|
||||
FakeMatrixApi.api['GET']!
|
||||
['/client/r0/thirdparty/location?alias=1234']({}),
|
||||
response.map((i) => i.toJson()).toList(),
|
||||
);
|
||||
|
|
@ -1609,7 +1609,7 @@ void main() {
|
|||
|
||||
final response = await matrixApi.requestThirdPartyUsersByUserId('1234');
|
||||
expect(
|
||||
FakeMatrixApi.api['GET']['/client/r0/thirdparty/user?userid=1234']({}),
|
||||
FakeMatrixApi.api['GET'],
|
||||
response.map((i) => i.toJson()).toList(),
|
||||
);
|
||||
|
||||
|
|
@ -1621,7 +1621,7 @@ void main() {
|
|||
|
||||
final response = await matrixApi.requestOpenIdToken('1234', {});
|
||||
expect(
|
||||
FakeMatrixApi.api['POST']
|
||||
FakeMatrixApi.api['POST']!
|
||||
['/client/r0/user/1234/openid/request_token']({}),
|
||||
response.toJson(),
|
||||
);
|
||||
|
|
@ -1647,7 +1647,7 @@ void main() {
|
|||
};
|
||||
final ret = await matrixApi.postRoomKeysVersion(algorithm, authData);
|
||||
expect(
|
||||
FakeMatrixApi.api['POST']
|
||||
FakeMatrixApi.api['POST']!
|
||||
['/client/unstable/room_keys/version']({})['version'],
|
||||
ret);
|
||||
});
|
||||
|
|
@ -1656,7 +1656,7 @@ void main() {
|
|||
matrixApi.accessToken = '1234';
|
||||
|
||||
final ret = await matrixApi.getRoomKeysVersionCurrent();
|
||||
expect(FakeMatrixApi.api['GET']['/client/unstable/room_keys/version']({}),
|
||||
expect(FakeMatrixApi.api['GET'],
|
||||
ret.toJson());
|
||||
});
|
||||
test('putRoomKeysVersion', () async {
|
||||
|
|
@ -1696,7 +1696,7 @@ void main() {
|
|||
final ret = await matrixApi.postRoomKeysKeyRoomIdSessionId(
|
||||
roomId, sessionId, '5', session);
|
||||
expect(
|
||||
FakeMatrixApi.api['PUT'][
|
||||
FakeMatrixApi.api['PUT'],
|
||||
ret.toJson());
|
||||
});
|
||||
|
|
@ -1708,7 +1708,7 @@ void main() {
|
|||
final sessionId = 'ciM/JWTPrmiWPPZNkRLDPQYf9AW/I46bxyLSr+Bx5oU';
|
||||
final ret = await matrixApi.getRoomKeysSingleKey(roomId, sessionId, '5');
|
||||
expect(
|
||||
FakeMatrixApi.api['GET'][
|
||||
FakeMatrixApi.api['GET'],
|
||||
ret.toJson());
|
||||
});
|
||||
|
|
@ -1721,7 +1721,7 @@ void main() {
|
|||
final ret =
|
||||
await matrixApi.deleteRoomKeysSingleKey(roomId, sessionId, '5');
|
||||
expect(
|
||||
FakeMatrixApi.api['DELETE'][
|
||||
FakeMatrixApi.api['DELETE'],
|
||||
ret.toJson());
|
||||
});
|
||||
|
|
@ -1748,7 +1748,7 @@ void main() {
|
|||
});
|
||||
final ret = await matrixApi.postRoomKeysKeyRoomId(roomId, '5', session);
|
||||
expect(
|
||||
FakeMatrixApi.api['PUT'][
|
||||
FakeMatrixApi.api['PUT'],
|
||||
ret.toJson());
|
||||
});
|
||||
|
|
@ -1759,7 +1759,7 @@ void main() {
|
|||
final roomId = '!726s6s6q:example.com';
|
||||
final ret = await matrixApi.getRoomKeysRoom(roomId, '5');
|
||||
expect(
|
||||
FakeMatrixApi.api['GET'][
|
||||
FakeMatrixApi.api['GET'],
|
||||
ret.toJson());
|
||||
});
|
||||
|
|
@ -1770,7 +1770,7 @@ void main() {
|
|||
final roomId = '!726s6s6q:example.com';
|
||||
final ret = await matrixApi.deleteRoomKeysRoom(roomId, '5');
|
||||
expect(
|
||||
FakeMatrixApi.api['DELETE'][
|
||||
FakeMatrixApi.api['DELETE'],
|
||||
ret.toJson());
|
||||
});
|
||||
|
|
@ -1801,7 +1801,7 @@ void main() {
|
|||
});
|
||||
final ret = await matrixApi.postRoomKeysKey('5', session);
|
||||
expect(
|
||||
FakeMatrixApi.api['PUT']
|
||||
FakeMatrixApi.api['PUT']!
|
||||
['/client/unstable/room_keys/keys?version=5']({}),
|
||||
ret.toJson());
|
||||
});
|
||||
|
|
@ -1811,7 +1811,7 @@ void main() {
|
|||
|
||||
final ret = await matrixApi.getRoomKeys('5');
|
||||
expect(
|
||||
FakeMatrixApi.api['GET']
|
||||
FakeMatrixApi.api['GET']!
|
||||
['/client/unstable/room_keys/keys?version=5']({}),
|
||||
ret.toJson());
|
||||
});
|
||||
|
|
@ -1821,7 +1821,7 @@ void main() {
|
|||
|
||||
final ret = await matrixApi.deleteRoomKeys('5');
|
||||
expect(
|
||||
FakeMatrixApi.api['DELETE']
|
||||
FakeMatrixApi.api['DELETE']!
|
||||
['/client/unstable/room_keys/keys?version=5']({}),
|
||||
ret.toJson());
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// @dart=2.9
|
||||
|
||||
/* MIT License
|
||||
*
|
||||
* Copyright (C) 2019, 2020, 2021 Famedly GmbH
|
||||
|
|
|
|||
Loading…
Reference in New Issue