refactor: enable more linter rules
enable prefer_final_locals and prefer_final_in_for_each linter rules
This commit is contained in:
parent
545ce26e39
commit
ffef732103
|
|
@ -5,6 +5,8 @@ linter:
|
||||||
- camel_case_types
|
- camel_case_types
|
||||||
- avoid_print
|
- avoid_print
|
||||||
- constant_identifier_names
|
- constant_identifier_names
|
||||||
|
- prefer_final_locals
|
||||||
|
- prefer_final_in_for_each
|
||||||
|
|
||||||
analyzer:
|
analyzer:
|
||||||
errors:
|
errors:
|
||||||
|
|
|
||||||
|
|
@ -199,7 +199,8 @@ class Encryption {
|
||||||
final messageIndexValue = event.eventId +
|
final messageIndexValue = event.eventId +
|
||||||
'|' +
|
'|' +
|
||||||
event.originServerTs.millisecondsSinceEpoch.toString();
|
event.originServerTs.millisecondsSinceEpoch.toString();
|
||||||
var haveIndex = inboundGroupSession.indexes.containsKey(messageIndexKey);
|
final haveIndex =
|
||||||
|
inboundGroupSession.indexes.containsKey(messageIndexKey);
|
||||||
if (haveIndex &&
|
if (haveIndex &&
|
||||||
inboundGroupSession.indexes[messageIndexKey] != messageIndexValue) {
|
inboundGroupSession.indexes[messageIndexKey] != messageIndexValue) {
|
||||||
Logs().e('[Decrypt] Could not decrypt due to a corrupted session.');
|
Logs().e('[Decrypt] Could not decrypt due to a corrupted session.');
|
||||||
|
|
@ -342,7 +343,7 @@ class Encryption {
|
||||||
'type': type,
|
'type': type,
|
||||||
'room_id': roomId,
|
'room_id': roomId,
|
||||||
};
|
};
|
||||||
var encryptedPayload = <String, dynamic>{
|
final encryptedPayload = <String, dynamic>{
|
||||||
'algorithm': AlgorithmTypes.megolmV1AesSha2,
|
'algorithm': AlgorithmTypes.megolmV1AesSha2,
|
||||||
'ciphertext':
|
'ciphertext':
|
||||||
sess.outboundGroupSession.encrypt(json.encode(payloadContent)),
|
sess.outboundGroupSession.encrypt(json.encode(payloadContent)),
|
||||||
|
|
|
||||||
|
|
@ -625,7 +625,7 @@ class KeyManager {
|
||||||
}) async {
|
}) async {
|
||||||
if (tryOnlineBackup && await isCached()) {
|
if (tryOnlineBackup && await isCached()) {
|
||||||
// let's first check our online key backup store thingy...
|
// let's first check our online key backup store thingy...
|
||||||
var hadPreviously =
|
final hadPreviously =
|
||||||
getInboundGroupSession(room.id, sessionId, senderKey) != null;
|
getInboundGroupSession(room.id, sessionId, senderKey) != null;
|
||||||
try {
|
try {
|
||||||
await loadSingleKey(room.id, sessionId);
|
await loadSingleKey(room.id, sessionId);
|
||||||
|
|
@ -894,7 +894,7 @@ class KeyManager {
|
||||||
'request_id': request.requestId,
|
'request_id': request.requestId,
|
||||||
'requesting_device_id': client.deviceID,
|
'requesting_device_id': client.deviceID,
|
||||||
};
|
};
|
||||||
var data = <String, Map<String, Map<String, dynamic>>>{};
|
final data = <String, Map<String, Map<String, dynamic>>>{};
|
||||||
for (final device in request.devices) {
|
for (final device in request.devices) {
|
||||||
if (!data.containsKey(device.userId)) {
|
if (!data.containsKey(device.userId)) {
|
||||||
data[device.userId] = {};
|
data[device.userId] = {};
|
||||||
|
|
|
||||||
|
|
@ -338,7 +338,7 @@ class OlmManager {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (existingSessions != null) {
|
if (existingSessions != null) {
|
||||||
for (var session in existingSessions) {
|
for (final session in existingSessions) {
|
||||||
if (type == 0 && session.session.matches_inbound(body) == true) {
|
if (type == 0 && session.session.matches_inbound(body) == true) {
|
||||||
try {
|
try {
|
||||||
plaintext = session.session.decrypt(type, body);
|
plaintext = session.session.decrypt(type, body);
|
||||||
|
|
@ -365,7 +365,7 @@ class OlmManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plaintext == null) {
|
if (plaintext == null) {
|
||||||
var newSession = olm.Session();
|
final newSession = olm.Session();
|
||||||
try {
|
try {
|
||||||
newSession.create_inbound_from(_olmAccount, senderKey, body);
|
newSession.create_inbound_from(_olmAccount, senderKey, body);
|
||||||
_olmAccount.remove_one_time_keys(newSession);
|
_olmAccount.remove_one_time_keys(newSession);
|
||||||
|
|
@ -518,8 +518,8 @@ class OlmManager {
|
||||||
Future<void> startOutgoingOlmSessions(List<DeviceKeys> deviceKeys) async {
|
Future<void> startOutgoingOlmSessions(List<DeviceKeys> deviceKeys) async {
|
||||||
Logs().v(
|
Logs().v(
|
||||||
'[OlmManager] Starting session with ${deviceKeys.length} devices...');
|
'[OlmManager] Starting session with ${deviceKeys.length} devices...');
|
||||||
var requestingKeysFrom = <String, Map<String, String>>{};
|
final requestingKeysFrom = <String, Map<String, String>>{};
|
||||||
for (var device in deviceKeys) {
|
for (final device in deviceKeys) {
|
||||||
if (requestingKeysFrom[device.userId] == null) {
|
if (requestingKeysFrom[device.userId] == null) {
|
||||||
requestingKeysFrom[device.userId] = {};
|
requestingKeysFrom[device.userId] = {};
|
||||||
}
|
}
|
||||||
|
|
@ -529,20 +529,21 @@ class OlmManager {
|
||||||
final response =
|
final response =
|
||||||
await client.requestOneTimeKeys(requestingKeysFrom, timeout: 10000);
|
await client.requestOneTimeKeys(requestingKeysFrom, timeout: 10000);
|
||||||
|
|
||||||
for (var userKeysEntry in response.oneTimeKeys.entries) {
|
for (final userKeysEntry in response.oneTimeKeys.entries) {
|
||||||
final userId = userKeysEntry.key;
|
final userId = userKeysEntry.key;
|
||||||
for (var deviceKeysEntry in userKeysEntry.value.entries) {
|
for (final deviceKeysEntry in userKeysEntry.value.entries) {
|
||||||
final deviceId = deviceKeysEntry.key;
|
final deviceId = deviceKeysEntry.key;
|
||||||
final fingerprintKey =
|
final fingerprintKey =
|
||||||
client.userDeviceKeys[userId].deviceKeys[deviceId].ed25519Key;
|
client.userDeviceKeys[userId].deviceKeys[deviceId].ed25519Key;
|
||||||
final identityKey =
|
final identityKey =
|
||||||
client.userDeviceKeys[userId].deviceKeys[deviceId].curve25519Key;
|
client.userDeviceKeys[userId].deviceKeys[deviceId].curve25519Key;
|
||||||
for (Map<String, dynamic> deviceKey in deviceKeysEntry.value.values) {
|
for (final Map<String, dynamic> deviceKey
|
||||||
|
in deviceKeysEntry.value.values) {
|
||||||
if (!deviceKey.checkJsonSignature(fingerprintKey, userId, deviceId)) {
|
if (!deviceKey.checkJsonSignature(fingerprintKey, userId, deviceId)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Logs().v('[OlmManager] Starting session with $userId:$deviceId');
|
Logs().v('[OlmManager] Starting session with $userId:$deviceId');
|
||||||
var session = olm.Session();
|
final session = olm.Session();
|
||||||
try {
|
try {
|
||||||
session.create_outbound(_olmAccount, identityKey, deviceKey['key']);
|
session.create_outbound(_olmAccount, identityKey, deviceKey['key']);
|
||||||
await storeOlmSession(OlmSession(
|
await storeOlmSession(OlmSession(
|
||||||
|
|
@ -608,7 +609,7 @@ class OlmManager {
|
||||||
List<DeviceKeys> deviceKeys,
|
List<DeviceKeys> deviceKeys,
|
||||||
String type,
|
String type,
|
||||||
Map<String, dynamic> payload) async {
|
Map<String, dynamic> payload) async {
|
||||||
var data = <String, Map<String, Map<String, dynamic>>>{};
|
final data = <String, Map<String, Map<String, dynamic>>>{};
|
||||||
// first check if any of our sessions we want to encrypt for are in the database
|
// first check if any of our sessions we want to encrypt for are in the database
|
||||||
if (client.database != null) {
|
if (client.database != null) {
|
||||||
await getOlmSessionsForDevicesFromDatabase(
|
await getOlmSessionsForDevicesFromDatabase(
|
||||||
|
|
|
||||||
|
|
@ -560,8 +560,8 @@ class Client extends MatrixApi {
|
||||||
/// profile will be requested from the homserver.
|
/// profile will be requested from the homserver.
|
||||||
Future<Profile> get ownProfile async {
|
Future<Profile> get ownProfile async {
|
||||||
if (rooms.isNotEmpty) {
|
if (rooms.isNotEmpty) {
|
||||||
var profileSet = <Profile>{};
|
final profileSet = <Profile>{};
|
||||||
for (var room in rooms) {
|
for (final room in rooms) {
|
||||||
final user = room.getUserByMXIDSync(userID);
|
final user = room.getUserByMXIDSync(userID);
|
||||||
profileSet.add(Profile.fromJson(user.content));
|
profileSet.add(Profile.fromJson(user.content));
|
||||||
}
|
}
|
||||||
|
|
@ -604,16 +604,16 @@ class Client extends MatrixApi {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<List<Room>> get archive async {
|
Future<List<Room>> get archive async {
|
||||||
var archiveList = <Room>[];
|
final archiveList = <Room>[];
|
||||||
final syncResp = await sync(
|
final syncResp = await sync(
|
||||||
filter: '{"room":{"include_leave":true,"timeline":{"limit":10}}}',
|
filter: '{"room":{"include_leave":true,"timeline":{"limit":10}}}',
|
||||||
timeout: 0,
|
timeout: 0,
|
||||||
);
|
);
|
||||||
if (syncResp.rooms.leave is Map<String, dynamic>) {
|
if (syncResp.rooms.leave is Map<String, dynamic>) {
|
||||||
for (var entry in syncResp.rooms.leave.entries) {
|
for (final entry in syncResp.rooms.leave.entries) {
|
||||||
final id = entry.key;
|
final id = entry.key;
|
||||||
final room = entry.value;
|
final room = entry.value;
|
||||||
var leftRoom = Room(
|
final leftRoom = Room(
|
||||||
id: id,
|
id: id,
|
||||||
membership: Membership.leave,
|
membership: Membership.leave,
|
||||||
client: this,
|
client: this,
|
||||||
|
|
@ -622,7 +622,7 @@ class Client extends MatrixApi {
|
||||||
<String, BasicRoomEvent>{},
|
<String, BasicRoomEvent>{},
|
||||||
mHeroes: []);
|
mHeroes: []);
|
||||||
if (room.timeline?.events != null) {
|
if (room.timeline?.events != null) {
|
||||||
for (var event in room.timeline.events) {
|
for (final event in room.timeline.events) {
|
||||||
leftRoom.setState(Event.fromMatrixEvent(
|
leftRoom.setState(Event.fromMatrixEvent(
|
||||||
event,
|
event,
|
||||||
leftRoom,
|
leftRoom,
|
||||||
|
|
@ -631,7 +631,7 @@ class Client extends MatrixApi {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (room.state != null) {
|
if (room.state != null) {
|
||||||
for (var event in room.state) {
|
for (final event in room.state) {
|
||||||
leftRoom.setState(Event.fromMatrixEvent(
|
leftRoom.setState(Event.fromMatrixEvent(
|
||||||
event,
|
event,
|
||||||
leftRoom,
|
leftRoom,
|
||||||
|
|
@ -1161,7 +1161,7 @@ class Client extends MatrixApi {
|
||||||
final id = entry.key;
|
final id = entry.key;
|
||||||
final room = entry.value;
|
final room = entry.value;
|
||||||
|
|
||||||
var update = RoomUpdate.fromSyncRoomUpdate(room, id);
|
final update = RoomUpdate.fromSyncRoomUpdate(room, id);
|
||||||
if (database != null) {
|
if (database != null) {
|
||||||
// TODO: This method seems to be rather slow for some updates
|
// TODO: This method seems to be rather slow for some updates
|
||||||
// Perhaps don't dynamically build that one query?
|
// Perhaps don't dynamically build that one query?
|
||||||
|
|
@ -1251,14 +1251,14 @@ class Client extends MatrixApi {
|
||||||
var room = getRoomById(id);
|
var room = getRoomById(id);
|
||||||
room ??= Room(id: id);
|
room ??= Room(id: id);
|
||||||
|
|
||||||
var receiptStateContent =
|
final receiptStateContent =
|
||||||
room.roomAccountData['m.receipt']?.content ?? {};
|
room.roomAccountData['m.receipt']?.content ?? {};
|
||||||
for (var eventEntry in event['content'].entries) {
|
for (final eventEntry in event['content'].entries) {
|
||||||
final String eventID = eventEntry.key;
|
final String eventID = eventEntry.key;
|
||||||
if (event['content'][eventID]['m.read'] != null) {
|
if (event['content'][eventID]['m.read'] != null) {
|
||||||
final Map<String, dynamic> userTimestampMap =
|
final Map<String, dynamic> userTimestampMap =
|
||||||
event['content'][eventID]['m.read'];
|
event['content'][eventID]['m.read'];
|
||||||
for (var userTimestampMapEntry in userTimestampMap.entries) {
|
for (final userTimestampMapEntry in userTimestampMap.entries) {
|
||||||
final mxid = userTimestampMapEntry.key;
|
final mxid = userTimestampMapEntry.key;
|
||||||
|
|
||||||
// Remove previous receipt event from this user
|
// Remove previous receipt event from this user
|
||||||
|
|
@ -1372,9 +1372,9 @@ class Client extends MatrixApi {
|
||||||
|
|
||||||
// Does the chat already exist in the list rooms?
|
// Does the chat already exist in the list rooms?
|
||||||
if (!found && !isLeftRoom) {
|
if (!found && !isLeftRoom) {
|
||||||
var position = chatUpdate.membership == Membership.invite ? 0 : j;
|
final position = chatUpdate.membership == Membership.invite ? 0 : j;
|
||||||
// Add the new chat to the list
|
// Add the new chat to the list
|
||||||
var newRoom = Room(
|
final newRoom = Room(
|
||||||
id: chatUpdate.id,
|
id: chatUpdate.id,
|
||||||
membership: chatUpdate.membership,
|
membership: chatUpdate.membership,
|
||||||
prev_batch: chatUpdate.prev_batch,
|
prev_batch: chatUpdate.prev_batch,
|
||||||
|
|
@ -1434,9 +1434,9 @@ class Client extends MatrixApi {
|
||||||
case EventUpdateType.timeline:
|
case EventUpdateType.timeline:
|
||||||
case EventUpdateType.state:
|
case EventUpdateType.state:
|
||||||
case EventUpdateType.inviteState:
|
case EventUpdateType.inviteState:
|
||||||
var stateEvent =
|
final stateEvent =
|
||||||
Event.fromJson(eventUpdate.content, room, eventUpdate.sortOrder);
|
Event.fromJson(eventUpdate.content, room, eventUpdate.sortOrder);
|
||||||
var prevState = room.getState(stateEvent.type, stateEvent.stateKey);
|
final prevState = room.getState(stateEvent.type, stateEvent.stateKey);
|
||||||
if (eventUpdate.type == EventUpdateType.timeline &&
|
if (eventUpdate.type == EventUpdateType.timeline &&
|
||||||
prevState != null &&
|
prevState != null &&
|
||||||
prevState.sortOrder > stateEvent.sortOrder) {
|
prevState.sortOrder > stateEvent.sortOrder) {
|
||||||
|
|
@ -1514,12 +1514,12 @@ sort order of ${prevState.sortOrder}. This should never happen...''');
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Set<String>> _getUserIdsInEncryptedRooms() async {
|
Future<Set<String>> _getUserIdsInEncryptedRooms() async {
|
||||||
var userIds = <String>{};
|
final userIds = <String>{};
|
||||||
for (final room in rooms) {
|
for (final room in rooms) {
|
||||||
if (room.encrypted) {
|
if (room.encrypted) {
|
||||||
try {
|
try {
|
||||||
var userList = await room.requestParticipants();
|
final userList = await room.requestParticipants();
|
||||||
for (var user in userList) {
|
for (final user in userList) {
|
||||||
if ([Membership.join, Membership.invite]
|
if ([Membership.join, Membership.invite]
|
||||||
.contains(user.membership)) {
|
.contains(user.membership)) {
|
||||||
userIds.add(user.id);
|
userIds.add(user.id);
|
||||||
|
|
@ -1539,7 +1539,7 @@ sort order of ${prevState.sortOrder}. This should never happen...''');
|
||||||
try {
|
try {
|
||||||
if (!isLogged()) return;
|
if (!isLogged()) return;
|
||||||
final dbActions = <Future<dynamic> Function()>[];
|
final dbActions = <Future<dynamic> Function()>[];
|
||||||
var trackedUserIds = await _getUserIdsInEncryptedRooms();
|
final trackedUserIds = await _getUserIdsInEncryptedRooms();
|
||||||
if (!isLogged()) return;
|
if (!isLogged()) return;
|
||||||
trackedUserIds.add(userID);
|
trackedUserIds.add(userID);
|
||||||
|
|
||||||
|
|
@ -1548,12 +1548,12 @@ sort order of ${prevState.sortOrder}. This should never happen...''');
|
||||||
.removeWhere((String userId, v) => !trackedUserIds.contains(userId));
|
.removeWhere((String userId, v) => !trackedUserIds.contains(userId));
|
||||||
|
|
||||||
// Check if there are outdated device key lists. Add it to the set.
|
// Check if there are outdated device key lists. Add it to the set.
|
||||||
var outdatedLists = <String, dynamic>{};
|
final outdatedLists = <String, dynamic>{};
|
||||||
for (var userId in trackedUserIds) {
|
for (final userId in trackedUserIds) {
|
||||||
if (!userDeviceKeys.containsKey(userId)) {
|
if (!userDeviceKeys.containsKey(userId)) {
|
||||||
_userDeviceKeys[userId] = DeviceKeysList(userId, this);
|
_userDeviceKeys[userId] = DeviceKeysList(userId, this);
|
||||||
}
|
}
|
||||||
var deviceKeysList = userDeviceKeys[userId];
|
final deviceKeysList = userDeviceKeys[userId];
|
||||||
if (deviceKeysList.outdated &&
|
if (deviceKeysList.outdated &&
|
||||||
(!_keyQueryFailures.containsKey(userId.domain) ||
|
(!_keyQueryFailures.containsKey(userId.domain) ||
|
||||||
DateTime.now()
|
DateTime.now()
|
||||||
|
|
@ -1791,8 +1791,8 @@ sort order of ${prevState.sortOrder}. This should never happen...''');
|
||||||
String messageId,
|
String messageId,
|
||||||
}) async {
|
}) async {
|
||||||
// Send with send-to-device messaging
|
// Send with send-to-device messaging
|
||||||
var data = <String, Map<String, Map<String, dynamic>>>{};
|
final data = <String, Map<String, Map<String, dynamic>>>{};
|
||||||
for (var user in users) {
|
for (final user in users) {
|
||||||
data[user] = {};
|
data[user] = {};
|
||||||
data[user]['*'] = message;
|
data[user]['*'] = message;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -244,7 +244,7 @@ class Event extends MatrixEvent {
|
||||||
'redacted_because': redactedBecause.toJson(),
|
'redacted_because': redactedBecause.toJson(),
|
||||||
};
|
};
|
||||||
prevContent = null;
|
prevContent = null;
|
||||||
var contentKeyWhiteList = <String>[];
|
final contentKeyWhiteList = <String>[];
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case EventTypes.RoomMember:
|
case EventTypes.RoomMember:
|
||||||
contentKeyWhiteList.add('membership');
|
contentKeyWhiteList.add('membership');
|
||||||
|
|
@ -295,8 +295,8 @@ class Event extends MatrixEvent {
|
||||||
/// Returns a list of [Receipt] instances for this event.
|
/// Returns a list of [Receipt] instances for this event.
|
||||||
List<Receipt> get receipts {
|
List<Receipt> get receipts {
|
||||||
if (!(room.roomAccountData.containsKey('m.receipt'))) return [];
|
if (!(room.roomAccountData.containsKey('m.receipt'))) return [];
|
||||||
var receiptsList = <Receipt>[];
|
final receiptsList = <Receipt>[];
|
||||||
for (var entry in room.roomAccountData['m.receipt'].content.entries) {
|
for (final entry in room.roomAccountData['m.receipt'].content.entries) {
|
||||||
if (entry.value['event_id'] == eventId) {
|
if (entry.value['event_id'] == eventId) {
|
||||||
receiptsList.add(Receipt(room.getUserByMXIDSync(entry.key),
|
receiptsList.add(Receipt(room.getUserByMXIDSync(entry.key),
|
||||||
DateTime.fromMillisecondsSinceEpoch(entry.value['ts'])));
|
DateTime.fromMillisecondsSinceEpoch(entry.value['ts'])));
|
||||||
|
|
@ -486,7 +486,7 @@ class Event extends MatrixEvent {
|
||||||
getThumbnail = mxcUrl != attachmentMxcUrl;
|
getThumbnail = mxcUrl != attachmentMxcUrl;
|
||||||
// Is this file storeable?
|
// Is this file storeable?
|
||||||
final thisInfoMap = getThumbnail ? thumbnailInfoMap : infoMap;
|
final thisInfoMap = getThumbnail ? thumbnailInfoMap : infoMap;
|
||||||
var storeable = room.client.database != null &&
|
final storeable = room.client.database != null &&
|
||||||
thisInfoMap['size'] is int &&
|
thisInfoMap['size'] is int &&
|
||||||
thisInfoMap['size'] <= room.client.database.maxFileSize;
|
thisInfoMap['size'] <= room.client.database.maxFileSize;
|
||||||
|
|
||||||
|
|
@ -676,7 +676,7 @@ class Event extends MatrixEvent {
|
||||||
// aggregated edits
|
// aggregated edits
|
||||||
if (allEditEvents.isNotEmpty) {
|
if (allEditEvents.isNotEmpty) {
|
||||||
allEditEvents.sort((a, b) => a.sortOrder - b.sortOrder > 0 ? 1 : -1);
|
allEditEvents.sort((a, b) => a.sortOrder - b.sortOrder > 0 ? 1 : -1);
|
||||||
var rawEvent = allEditEvents.last.toJson();
|
final rawEvent = allEditEvents.last.toJson();
|
||||||
// update the content of the new event to render
|
// update the content of the new event to render
|
||||||
if (rawEvent['content']['m.new_content'] is Map) {
|
if (rawEvent['content']['m.new_content'] is Map) {
|
||||||
rawEvent['content'] = rawEvent['content']['m.new_content'];
|
rawEvent['content'] = rawEvent['content']['m.new_content'];
|
||||||
|
|
|
||||||
|
|
@ -318,7 +318,7 @@ class Room {
|
||||||
/// Returns a list of all current typing users.
|
/// Returns a list of all current typing users.
|
||||||
List<User> get typingUsers {
|
List<User> get typingUsers {
|
||||||
if (!ephemerals.containsKey('m.typing')) return [];
|
if (!ephemerals.containsKey('m.typing')) return [];
|
||||||
List<dynamic> typingMxid = ephemerals['m.typing'].content['user_ids'];
|
final List<dynamic> typingMxid = ephemerals['m.typing'].content['user_ids'];
|
||||||
return typingMxid.cast<String>().map(getUserByMXIDSync).toList();
|
return typingMxid.cast<String>().map(getUserByMXIDSync).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -367,7 +367,7 @@ class Room {
|
||||||
heroes = mHeroes;
|
heroes = mHeroes;
|
||||||
} else {
|
} else {
|
||||||
if (states[EventTypes.RoomMember] is Map<String, dynamic>) {
|
if (states[EventTypes.RoomMember] is Map<String, dynamic>) {
|
||||||
for (var entry in states[EventTypes.RoomMember].entries) {
|
for (final entry in states[EventTypes.RoomMember].entries) {
|
||||||
final state = entry.value;
|
final state = entry.value;
|
||||||
if (state.type == EventTypes.RoomMember &&
|
if (state.type == EventTypes.RoomMember &&
|
||||||
state.stateKey != client?.userID) heroes.add(state.stateKey);
|
state.stateKey != client?.userID) heroes.add(state.stateKey);
|
||||||
|
|
@ -679,7 +679,7 @@ class Room {
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
// Send event
|
// Send event
|
||||||
var content = <String, dynamic>{
|
final content = <String, dynamic>{
|
||||||
'msgtype': file.msgType,
|
'msgtype': file.msgType,
|
||||||
'body': file.name,
|
'body': file.name,
|
||||||
'filename': file.name,
|
'filename': file.name,
|
||||||
|
|
@ -992,7 +992,7 @@ class Room {
|
||||||
|
|
||||||
/// Sets this room as a direct chat for this user if not already.
|
/// Sets this room as a direct chat for this user if not already.
|
||||||
Future<void> addToDirectChat(String userID) async {
|
Future<void> addToDirectChat(String userID) async {
|
||||||
var directChats = client.directChats;
|
final directChats = client.directChats;
|
||||||
if (directChats[userID] is List) {
|
if (directChats[userID] is List) {
|
||||||
if (!directChats[userID].contains(id)) {
|
if (!directChats[userID].contains(id)) {
|
||||||
directChats[userID].add(id);
|
directChats[userID].add(id);
|
||||||
|
|
@ -1013,7 +1013,7 @@ class Room {
|
||||||
|
|
||||||
/// Removes this room from all direct chat tags.
|
/// Removes this room from all direct chat tags.
|
||||||
Future<void> removeFromDirectChat() async {
|
Future<void> removeFromDirectChat() async {
|
||||||
var directChats = client.directChats;
|
final directChats = client.directChats;
|
||||||
if (directChats[directChatMatrixID] is List &&
|
if (directChats[directChatMatrixID] is List &&
|
||||||
directChats[directChatMatrixID].contains(id)) {
|
directChats[directChatMatrixID].contains(id)) {
|
||||||
directChats[directChatMatrixID].remove(id);
|
directChats[directChatMatrixID].remove(id);
|
||||||
|
|
@ -1112,7 +1112,7 @@ class Room {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var newRoomAccountData = <String, BasicRoomEvent>{};
|
final newRoomAccountData = <String, BasicRoomEvent>{};
|
||||||
if (roomAccountData != null) {
|
if (roomAccountData != null) {
|
||||||
var rawRoomAccountData;
|
var rawRoomAccountData;
|
||||||
if (roomAccountData is Future) {
|
if (roomAccountData is Future) {
|
||||||
|
|
@ -1160,7 +1160,7 @@ class Room {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var timeline = Timeline(
|
final timeline = Timeline(
|
||||||
room: this,
|
room: this,
|
||||||
events: events,
|
events: events,
|
||||||
onUpdate: onUpdate,
|
onUpdate: onUpdate,
|
||||||
|
|
@ -1177,9 +1177,9 @@ class Room {
|
||||||
/// list may not be complete. User [requestParticipants] in this
|
/// list may not be complete. User [requestParticipants] in this
|
||||||
/// case.
|
/// case.
|
||||||
List<User> getParticipants() {
|
List<User> getParticipants() {
|
||||||
var userList = <User>[];
|
final userList = <User>[];
|
||||||
if (states[EventTypes.RoomMember] is Map<String, dynamic>) {
|
if (states[EventTypes.RoomMember] is Map<String, dynamic>) {
|
||||||
for (var entry in states[EventTypes.RoomMember].entries) {
|
for (final entry in states[EventTypes.RoomMember].entries) {
|
||||||
final state = entry.value;
|
final state = entry.value;
|
||||||
if (state.type == EventTypes.RoomMember) userList.add(state.asUser);
|
if (state.type == EventTypes.RoomMember) userList.add(state.asUser);
|
||||||
}
|
}
|
||||||
|
|
@ -1216,7 +1216,7 @@ class Room {
|
||||||
|
|
||||||
/// Checks if the local participant list of joined and invited users is complete.
|
/// Checks if the local participant list of joined and invited users is complete.
|
||||||
bool get participantListComplete {
|
bool get participantListComplete {
|
||||||
var knownParticipants = getParticipants();
|
final knownParticipants = getParticipants();
|
||||||
knownParticipants.removeWhere(
|
knownParticipants.removeWhere(
|
||||||
(u) => ![Membership.join, Membership.invite].contains(u.membership));
|
(u) => ![Membership.join, Membership.invite].contains(u.membership));
|
||||||
return knownParticipants.length ==
|
return knownParticipants.length ==
|
||||||
|
|
@ -1539,7 +1539,7 @@ class Room {
|
||||||
} else {
|
} else {
|
||||||
messageID = txid;
|
messageID = txid;
|
||||||
}
|
}
|
||||||
var data = <String, dynamic>{};
|
final data = <String, dynamic>{};
|
||||||
if (reason != null) data['reason'] = reason;
|
if (reason != null) data['reason'] = reason;
|
||||||
return await client.redact(
|
return await client.redact(
|
||||||
id,
|
id,
|
||||||
|
|
@ -1660,8 +1660,8 @@ class Room {
|
||||||
|
|
||||||
/// Returns all aliases for this room.
|
/// Returns all aliases for this room.
|
||||||
List<String> get aliases {
|
List<String> get aliases {
|
||||||
var aliases = <String>[];
|
final aliases = <String>[];
|
||||||
for (var aliasEvent in states[EventTypes.RoomAliases].values) {
|
for (final aliasEvent in states[EventTypes.RoomAliases].values) {
|
||||||
if (aliasEvent.content['aliases'] is List) {
|
if (aliasEvent.content['aliases'] is List) {
|
||||||
aliases.addAll(aliasEvent.content['aliases']);
|
aliases.addAll(aliasEvent.content['aliases']);
|
||||||
}
|
}
|
||||||
|
|
@ -1765,12 +1765,12 @@ class Room {
|
||||||
|
|
||||||
/// Returns all known device keys for all participants in this room.
|
/// Returns all known device keys for all participants in this room.
|
||||||
Future<List<DeviceKeys>> getUserDeviceKeys() async {
|
Future<List<DeviceKeys>> getUserDeviceKeys() async {
|
||||||
var deviceKeys = <DeviceKeys>[];
|
final deviceKeys = <DeviceKeys>[];
|
||||||
var users = await requestParticipants();
|
final users = await requestParticipants();
|
||||||
for (final user in users) {
|
for (final user in users) {
|
||||||
if ([Membership.invite, Membership.join].contains(user.membership) &&
|
if ([Membership.invite, Membership.join].contains(user.membership) &&
|
||||||
client.userDeviceKeys.containsKey(user.id)) {
|
client.userDeviceKeys.containsKey(user.id)) {
|
||||||
for (var deviceKeyEntry
|
for (final deviceKeyEntry
|
||||||
in client.userDeviceKeys[user.id].deviceKeys.values) {
|
in client.userDeviceKeys[user.id].deviceKeys.values) {
|
||||||
deviceKeys.add(deviceKeyEntry);
|
deviceKeys.add(deviceKeyEntry);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -262,7 +262,7 @@ class Timeline {
|
||||||
eventUpdate.type != EventUpdateType.history) {
|
eventUpdate.type != EventUpdateType.history) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var status = eventUpdate.content['status'] ??
|
final status = eventUpdate.content['status'] ??
|
||||||
(eventUpdate.content['unsigned'] is Map<String, dynamic>
|
(eventUpdate.content['unsigned'] is Map<String, dynamic>
|
||||||
? eventUpdate.content['unsigned'][messageSendingStatusKey]
|
? eventUpdate.content['unsigned'][messageSendingStatusKey]
|
||||||
: null) ??
|
: null) ??
|
||||||
|
|
@ -276,13 +276,13 @@ class Timeline {
|
||||||
Event.fromJson(eventUpdate.content, room, eventUpdate.sortOrder));
|
Event.fromJson(eventUpdate.content, room, eventUpdate.sortOrder));
|
||||||
}
|
}
|
||||||
} else if (status == -2) {
|
} else if (status == -2) {
|
||||||
var i = _findEvent(event_id: eventUpdate.content['event_id']);
|
final i = _findEvent(event_id: eventUpdate.content['event_id']);
|
||||||
if (i < events.length) {
|
if (i < events.length) {
|
||||||
removeAggregatedEvent(events[i]);
|
removeAggregatedEvent(events[i]);
|
||||||
events.removeAt(i);
|
events.removeAt(i);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var i = _findEvent(
|
final i = _findEvent(
|
||||||
event_id: eventUpdate.content['event_id'],
|
event_id: eventUpdate.content['event_id'],
|
||||||
unsigned_txid: eventUpdate.content['unsigned'] is Map
|
unsigned_txid: eventUpdate.content['unsigned'] is Map
|
||||||
? eventUpdate.content['unsigned']['transaction_id']
|
? eventUpdate.content['unsigned']['transaction_id']
|
||||||
|
|
@ -303,7 +303,7 @@ class Timeline {
|
||||||
}
|
}
|
||||||
addAggregatedEvent(events[i]);
|
addAggregatedEvent(events[i]);
|
||||||
} else {
|
} else {
|
||||||
var newEvent =
|
final newEvent =
|
||||||
Event.fromJson(eventUpdate.content, room, eventUpdate.sortOrder);
|
Event.fromJson(eventUpdate.content, room, eventUpdate.sortOrder);
|
||||||
|
|
||||||
if (eventUpdate.type == EventUpdateType.history &&
|
if (eventUpdate.type == EventUpdateType.history &&
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ class User extends Event {
|
||||||
String avatarUrl,
|
String avatarUrl,
|
||||||
Room room,
|
Room room,
|
||||||
}) {
|
}) {
|
||||||
var content = <String, String>{};
|
final content = <String, String>{};
|
||||||
if (membership != null) content['membership'] = membership;
|
if (membership != null) content['membership'] = membership;
|
||||||
if (displayName != null) content['displayname'] = displayName;
|
if (displayName != null) content['displayname'] = displayName;
|
||||||
if (avatarUrl != null) content['avatar_url'] = avatarUrl;
|
if (avatarUrl != null) content['avatar_url'] = avatarUrl;
|
||||||
|
|
@ -119,7 +119,7 @@ class User extends Event {
|
||||||
if (!formatLocalpart) {
|
if (!formatLocalpart) {
|
||||||
return stateKey.localpart;
|
return stateKey.localpart;
|
||||||
}
|
}
|
||||||
var words = stateKey.localpart.replaceAll('_', ' ').split(' ');
|
final words = stateKey.localpart.replaceAll('_', ' ').split(' ');
|
||||||
for (var i = 0; i < words.length; i++) {
|
for (var i = 0; i < words.length; i++) {
|
||||||
if (words[i].isNotEmpty) {
|
if (words[i].isNotEmpty) {
|
||||||
words[i] = words[i][0].toUpperCase() + words[i].substring(1);
|
words[i] = words[i][0].toUpperCase() + words[i].substring(1);
|
||||||
|
|
|
||||||
|
|
@ -85,7 +85,7 @@ abstract class EventLocalizations {
|
||||||
i18n.createdTheChat(event.sender.calcDisplayname()),
|
i18n.createdTheChat(event.sender.calcDisplayname()),
|
||||||
EventTypes.RoomTombstone: (event, i18n) => i18n.roomHasBeenUpgraded,
|
EventTypes.RoomTombstone: (event, i18n) => i18n.roomHasBeenUpgraded,
|
||||||
EventTypes.RoomJoinRules: (event, i18n) {
|
EventTypes.RoomJoinRules: (event, i18n) {
|
||||||
var joinRules = JoinRules.values.firstWhere(
|
final joinRules = JoinRules.values.firstWhere(
|
||||||
(r) =>
|
(r) =>
|
||||||
r.toString().replaceAll('JoinRules.', '') ==
|
r.toString().replaceAll('JoinRules.', '') ==
|
||||||
event.content['join_rule'],
|
event.content['join_rule'],
|
||||||
|
|
@ -170,7 +170,7 @@ abstract class EventLocalizations {
|
||||||
EventTypes.RoomAvatar: (event, i18n) =>
|
EventTypes.RoomAvatar: (event, i18n) =>
|
||||||
i18n.changedTheChatAvatar(event.sender.calcDisplayname()),
|
i18n.changedTheChatAvatar(event.sender.calcDisplayname()),
|
||||||
EventTypes.GuestAccess: (event, i18n) {
|
EventTypes.GuestAccess: (event, i18n) {
|
||||||
var guestAccess = GuestAccess.values.firstWhere(
|
final guestAccess = GuestAccess.values.firstWhere(
|
||||||
(r) =>
|
(r) =>
|
||||||
r.toString().replaceAll('GuestAccess.', '') ==
|
r.toString().replaceAll('GuestAccess.', '') ==
|
||||||
event.content['guest_access'],
|
event.content['guest_access'],
|
||||||
|
|
@ -183,7 +183,7 @@ abstract class EventLocalizations {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
EventTypes.HistoryVisibility: (event, i18n) {
|
EventTypes.HistoryVisibility: (event, i18n) {
|
||||||
var historyVisibility = HistoryVisibility.values.firstWhere(
|
final historyVisibility = HistoryVisibility.values.firstWhere(
|
||||||
(r) =>
|
(r) =>
|
||||||
r.toString().replaceAll('HistoryVisibility.', '') ==
|
r.toString().replaceAll('HistoryVisibility.', '') ==
|
||||||
event.content['history_visibility'],
|
event.content['history_visibility'],
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ class EventUpdate {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
var decrpytedEvent = await room.client.encryption.decryptRoomEvent(
|
final decrpytedEvent = await room.client.encryption.decryptRoomEvent(
|
||||||
room.id, Event.fromJson(content, room, sortOrder),
|
room.id, Event.fromJson(content, room, sortOrder),
|
||||||
store: store, updateType: type);
|
store: store, updateType: type);
|
||||||
return EventUpdate(
|
return EventUpdate(
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,7 @@ class BlockLatexSyntax extends BlockSyntax {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<String> parseChildLines(BlockParser parser) {
|
List<String> parseChildLines(BlockParser parser) {
|
||||||
var childLines = <String>[];
|
final childLines = <String>[];
|
||||||
var first = true;
|
var first = true;
|
||||||
while (!parser.isDone) {
|
while (!parser.isDone) {
|
||||||
final match = endPattern.firstMatch(parser.current);
|
final match = endPattern.firstMatch(parser.current);
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ void main() {
|
||||||
/// All Tests related to the ChatTime
|
/// All Tests related to the ChatTime
|
||||||
group('Canonical Json', () {
|
group('Canonical Json', () {
|
||||||
Logs().level = Level.error;
|
Logs().level = Level.error;
|
||||||
var textMap = <String, Map<String, dynamic>>{
|
final textMap = <String, Map<String, dynamic>>{
|
||||||
'{}': {},
|
'{}': {},
|
||||||
'{"one":1,"two":"Two"}': {'one': 1, 'two': 'Two'},
|
'{"one":1,"two":"Two"}': {'one': 1, 'two': 'Two'},
|
||||||
'{"a":"1","b":"2"}': {'b': '2', 'a': '1'},
|
'{"a":"1","b":"2"}': {'b': '2', 'a': '1'},
|
||||||
|
|
|
||||||
|
|
@ -95,9 +95,9 @@ void main() {
|
||||||
final available = await matrix.usernameAvailable('testuser');
|
final available = await matrix.usernameAvailable('testuser');
|
||||||
expect(available, true);
|
expect(available, true);
|
||||||
|
|
||||||
var loginStateFuture = matrix.onLoginStateChanged.stream.first;
|
final loginStateFuture = matrix.onLoginStateChanged.stream.first;
|
||||||
var firstSyncFuture = matrix.onFirstSync.stream.first;
|
final firstSyncFuture = matrix.onFirstSync.stream.first;
|
||||||
var syncFuture = matrix.onSync.stream.first;
|
final syncFuture = matrix.onSync.stream.first;
|
||||||
|
|
||||||
await matrix.init(
|
await matrix.init(
|
||||||
newToken: 'abcd',
|
newToken: 'abcd',
|
||||||
|
|
@ -110,9 +110,9 @@ void main() {
|
||||||
|
|
||||||
await Future.delayed(Duration(milliseconds: 50));
|
await Future.delayed(Duration(milliseconds: 50));
|
||||||
|
|
||||||
var loginState = await loginStateFuture;
|
final loginState = await loginStateFuture;
|
||||||
var firstSync = await firstSyncFuture;
|
final firstSync = await firstSyncFuture;
|
||||||
var sync = await syncFuture;
|
final sync = await syncFuture;
|
||||||
|
|
||||||
expect(loginState, LoginState.logged);
|
expect(loginState, LoginState.logged);
|
||||||
expect(firstSync, true);
|
expect(firstSync, true);
|
||||||
|
|
@ -203,7 +203,7 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Logout', () async {
|
test('Logout', () async {
|
||||||
var loginStateFuture = matrix.onLoginStateChanged.stream.first;
|
final loginStateFuture = matrix.onLoginStateChanged.stream.first;
|
||||||
await matrix.logout();
|
await matrix.logout();
|
||||||
|
|
||||||
expect(matrix.accessToken == null, true);
|
expect(matrix.accessToken == null, true);
|
||||||
|
|
@ -213,14 +213,14 @@ void main() {
|
||||||
expect(matrix.deviceName == null, true);
|
expect(matrix.deviceName == null, true);
|
||||||
expect(matrix.prevBatch == null, true);
|
expect(matrix.prevBatch == null, true);
|
||||||
|
|
||||||
var loginState = await loginStateFuture;
|
final loginState = await loginStateFuture;
|
||||||
expect(loginState, LoginState.loggedOut);
|
expect(loginState, LoginState.loggedOut);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Room Update Test', () async {
|
test('Room Update Test', () async {
|
||||||
await matrix.onRoomUpdate.close();
|
await matrix.onRoomUpdate.close();
|
||||||
|
|
||||||
var roomUpdateList = await roomUpdateListFuture;
|
final roomUpdateList = await roomUpdateListFuture;
|
||||||
|
|
||||||
expect(roomUpdateList.length, 4);
|
expect(roomUpdateList.length, 4);
|
||||||
|
|
||||||
|
|
@ -242,7 +242,7 @@ void main() {
|
||||||
test('Event Update Test', () async {
|
test('Event Update Test', () async {
|
||||||
await matrix.onEvent.close();
|
await matrix.onEvent.close();
|
||||||
|
|
||||||
var eventUpdateList = await eventUpdateListFuture;
|
final eventUpdateList = await eventUpdateListFuture;
|
||||||
|
|
||||||
expect(eventUpdateList.length, 14);
|
expect(eventUpdateList.length, 14);
|
||||||
|
|
||||||
|
|
@ -303,7 +303,7 @@ void main() {
|
||||||
test('To Device Update Test', () async {
|
test('To Device Update Test', () async {
|
||||||
await matrix.onToDeviceEvent.close();
|
await matrix.onToDeviceEvent.close();
|
||||||
|
|
||||||
var eventUpdateList = await toDeviceUpdateListFuture;
|
final eventUpdateList = await toDeviceUpdateListFuture;
|
||||||
|
|
||||||
expect(eventUpdateList.length, 2);
|
expect(eventUpdateList.length, 2);
|
||||||
|
|
||||||
|
|
@ -351,7 +351,7 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('get archive', () async {
|
test('get archive', () async {
|
||||||
var archive = await matrix.archive;
|
final archive = await matrix.archive;
|
||||||
|
|
||||||
await Future.delayed(Duration(milliseconds: 50));
|
await Future.delayed(Duration(milliseconds: 50));
|
||||||
expect(archive.length, 2);
|
expect(archive.length, 2);
|
||||||
|
|
@ -526,7 +526,7 @@ void main() {
|
||||||
});
|
});
|
||||||
test('Test the fake store api', () async {
|
test('Test the fake store api', () async {
|
||||||
final database = await getDatabase(null);
|
final database = await getDatabase(null);
|
||||||
var client1 = Client(
|
final client1 = Client(
|
||||||
'testclient',
|
'testclient',
|
||||||
httpClient: FakeMatrixApi(),
|
httpClient: FakeMatrixApi(),
|
||||||
databaseBuilder: (_) => database,
|
databaseBuilder: (_) => database,
|
||||||
|
|
@ -546,7 +546,7 @@ void main() {
|
||||||
expect(client1.isLogged(), true);
|
expect(client1.isLogged(), true);
|
||||||
expect(client1.rooms.length, 2);
|
expect(client1.rooms.length, 2);
|
||||||
|
|
||||||
var client2 = Client(
|
final client2 = Client(
|
||||||
'testclient',
|
'testclient',
|
||||||
httpClient: FakeMatrixApi(),
|
httpClient: FakeMatrixApi(),
|
||||||
databaseBuilder: (_) => database,
|
databaseBuilder: (_) => database,
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ void main() {
|
||||||
test('me', () async {
|
test('me', () async {
|
||||||
FakeMatrixApi.calledEndpoints.clear();
|
FakeMatrixApi.calledEndpoints.clear();
|
||||||
await room.sendTextEvent('/me heya');
|
await room.sendTextEvent('/me heya');
|
||||||
var sent = getLastMessagePayload();
|
final sent = getLastMessagePayload();
|
||||||
expect(sent, {
|
expect(sent, {
|
||||||
'msgtype': 'm.emote',
|
'msgtype': 'm.emote',
|
||||||
'body': 'heya',
|
'body': 'heya',
|
||||||
|
|
@ -104,7 +104,7 @@ void main() {
|
||||||
test('plain', () async {
|
test('plain', () async {
|
||||||
FakeMatrixApi.calledEndpoints.clear();
|
FakeMatrixApi.calledEndpoints.clear();
|
||||||
await room.sendTextEvent('/plain *floof*');
|
await room.sendTextEvent('/plain *floof*');
|
||||||
var sent = getLastMessagePayload();
|
final sent = getLastMessagePayload();
|
||||||
expect(sent, {
|
expect(sent, {
|
||||||
'msgtype': 'm.text',
|
'msgtype': 'm.text',
|
||||||
'body': '*floof*',
|
'body': '*floof*',
|
||||||
|
|
@ -114,7 +114,7 @@ void main() {
|
||||||
test('html', () async {
|
test('html', () async {
|
||||||
FakeMatrixApi.calledEndpoints.clear();
|
FakeMatrixApi.calledEndpoints.clear();
|
||||||
await room.sendTextEvent('/html <b>yay</b>');
|
await room.sendTextEvent('/html <b>yay</b>');
|
||||||
var sent = getLastMessagePayload();
|
final sent = getLastMessagePayload();
|
||||||
expect(sent, {
|
expect(sent, {
|
||||||
'msgtype': 'm.text',
|
'msgtype': 'm.text',
|
||||||
'body': '<b>yay</b>',
|
'body': '<b>yay</b>',
|
||||||
|
|
@ -127,7 +127,7 @@ void main() {
|
||||||
FakeMatrixApi.calledEndpoints.clear();
|
FakeMatrixApi.calledEndpoints.clear();
|
||||||
await room.sendTextEvent('/react 🦊',
|
await room.sendTextEvent('/react 🦊',
|
||||||
inReplyTo: Event(eventId: '\$event'));
|
inReplyTo: Event(eventId: '\$event'));
|
||||||
var sent = getLastMessagePayload('m.reaction');
|
final sent = getLastMessagePayload('m.reaction');
|
||||||
expect(sent, {
|
expect(sent, {
|
||||||
'm.relates_to': {
|
'm.relates_to': {
|
||||||
'rel_type': 'm.annotation',
|
'rel_type': 'm.annotation',
|
||||||
|
|
@ -231,7 +231,7 @@ void main() {
|
||||||
test('myroomnick', () async {
|
test('myroomnick', () async {
|
||||||
FakeMatrixApi.calledEndpoints.clear();
|
FakeMatrixApi.calledEndpoints.clear();
|
||||||
await room.sendTextEvent('/myroomnick Foxies~');
|
await room.sendTextEvent('/myroomnick Foxies~');
|
||||||
var sent = getLastMessagePayload('m.room.member', client.userID);
|
final sent = getLastMessagePayload('m.room.member', client.userID);
|
||||||
expect(sent, {
|
expect(sent, {
|
||||||
'displayname': 'Foxies~',
|
'displayname': 'Foxies~',
|
||||||
'membership': 'join',
|
'membership': 'join',
|
||||||
|
|
@ -241,7 +241,7 @@ void main() {
|
||||||
test('myroomavatar', () async {
|
test('myroomavatar', () async {
|
||||||
FakeMatrixApi.calledEndpoints.clear();
|
FakeMatrixApi.calledEndpoints.clear();
|
||||||
await room.sendTextEvent('/myroomavatar mxc://beep/boop');
|
await room.sendTextEvent('/myroomavatar mxc://beep/boop');
|
||||||
var sent = getLastMessagePayload('m.room.member', client.userID);
|
final sent = getLastMessagePayload('m.room.member', client.userID);
|
||||||
expect(sent, {
|
expect(sent, {
|
||||||
'avatar_url': 'mxc://beep/boop',
|
'avatar_url': 'mxc://beep/boop',
|
||||||
'membership': 'join',
|
'membership': 'join',
|
||||||
|
|
|
||||||
|
|
@ -96,7 +96,7 @@ void main() {
|
||||||
client.userDeviceKeys[client.userID].deviceKeys['OTHERDEVICE'],
|
client.userDeviceKeys[client.userID].deviceKeys['OTHERDEVICE'],
|
||||||
client.userDeviceKeys['@othertest:fakeServer.notExisting'].masterKey
|
client.userDeviceKeys['@othertest:fakeServer.notExisting'].masterKey
|
||||||
]);
|
]);
|
||||||
var body = json.decode(FakeMatrixApi
|
final body = json.decode(FakeMatrixApi
|
||||||
.calledEndpoints['/client/r0/keys/signatures/upload'].first);
|
.calledEndpoints['/client/r0/keys/signatures/upload'].first);
|
||||||
expect(body['@test:fakeServer.notExisting'].containsKey('OTHERDEVICE'),
|
expect(body['@test:fakeServer.notExisting'].containsKey('OTHERDEVICE'),
|
||||||
true);
|
true);
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ void main() {
|
||||||
var olmEnabled = true;
|
var olmEnabled = true;
|
||||||
|
|
||||||
Client client;
|
Client client;
|
||||||
var otherClient = Client('othertestclient',
|
final otherClient = Client('othertestclient',
|
||||||
httpClient: FakeMatrixApi(), databaseBuilder: getDatabase);
|
httpClient: FakeMatrixApi(), databaseBuilder: getDatabase);
|
||||||
DeviceKeys device;
|
DeviceKeys device;
|
||||||
Map<String, dynamic> payload;
|
Map<String, dynamic> payload;
|
||||||
|
|
|
||||||
|
|
@ -56,13 +56,13 @@ void main() {
|
||||||
Logs().i('[LibOlm] Enabled: $olmEnabled');
|
Logs().i('[LibOlm] Enabled: $olmEnabled');
|
||||||
if (!olmEnabled) return;
|
if (!olmEnabled) return;
|
||||||
|
|
||||||
var matrix = await getClient();
|
final matrix = await getClient();
|
||||||
final requestRoom = matrix.getRoomById('!726s6s6q:example.com');
|
final requestRoom = matrix.getRoomById('!726s6s6q:example.com');
|
||||||
await matrix.encryption.keyManager.request(
|
await matrix.encryption.keyManager.request(
|
||||||
requestRoom, 'sessionId', validSenderKey,
|
requestRoom, 'sessionId', validSenderKey,
|
||||||
tryOnlineBackup: false);
|
tryOnlineBackup: false);
|
||||||
var foundEvent = false;
|
var foundEvent = false;
|
||||||
for (var entry in FakeMatrixApi.calledEndpoints.entries) {
|
for (final entry in FakeMatrixApi.calledEndpoints.entries) {
|
||||||
final payload = jsonDecode(entry.value.first);
|
final payload = jsonDecode(entry.value.first);
|
||||||
if (entry.key
|
if (entry.key
|
||||||
.startsWith('/client/r0/sendToDevice/m.room_key_request') &&
|
.startsWith('/client/r0/sendToDevice/m.room_key_request') &&
|
||||||
|
|
@ -84,7 +84,7 @@ void main() {
|
||||||
});
|
});
|
||||||
test('Reply To Request', () async {
|
test('Reply To Request', () async {
|
||||||
if (!olmEnabled) return;
|
if (!olmEnabled) return;
|
||||||
var matrix = await getClient();
|
final matrix = await getClient();
|
||||||
matrix.setUserId('@alice:example.com'); // we need to pretend to be alice
|
matrix.setUserId('@alice:example.com'); // we need to pretend to be alice
|
||||||
FakeMatrixApi.calledEndpoints.clear();
|
FakeMatrixApi.calledEndpoints.clear();
|
||||||
await matrix
|
await matrix
|
||||||
|
|
@ -279,7 +279,7 @@ void main() {
|
||||||
});
|
});
|
||||||
test('Receive shared keys', () async {
|
test('Receive shared keys', () async {
|
||||||
if (!olmEnabled) return;
|
if (!olmEnabled) return;
|
||||||
var matrix = await getClient();
|
final matrix = await getClient();
|
||||||
final requestRoom = matrix.getRoomById('!726s6s6q:example.com');
|
final requestRoom = matrix.getRoomById('!726s6s6q:example.com');
|
||||||
await matrix.encryption.keyManager.request(
|
await matrix.encryption.keyManager.request(
|
||||||
requestRoom, validSessionId, validSenderKey,
|
requestRoom, validSessionId, validSenderKey,
|
||||||
|
|
|
||||||
|
|
@ -425,7 +425,7 @@ void main() {
|
||||||
client1.userDeviceKeys[client1.userID].masterKey.setDirectVerified(false);
|
client1.userDeviceKeys[client1.userID].masterKey.setDirectVerified(false);
|
||||||
final req1 =
|
final req1 =
|
||||||
await client1.userDeviceKeys[client2.userID].startVerification();
|
await client1.userDeviceKeys[client2.userID].startVerification();
|
||||||
var evt = getLastSentEvent(req1);
|
final evt = getLastSentEvent(req1);
|
||||||
expect(req1.state, KeyVerificationState.waitingAccept);
|
expect(req1.state, KeyVerificationState.waitingAccept);
|
||||||
|
|
||||||
KeyVerification req2;
|
KeyVerification req2;
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,7 @@ void main() {
|
||||||
final roomId = '!someroom:example.org';
|
final roomId = '!someroom:example.org';
|
||||||
final sessionId = inbound.session_id();
|
final sessionId = inbound.session_id();
|
||||||
// set a payload...
|
// set a payload...
|
||||||
var sessionPayload = <String, dynamic>{
|
final sessionPayload = <String, dynamic>{
|
||||||
'algorithm': AlgorithmTypes.megolmV1AesSha2,
|
'algorithm': AlgorithmTypes.megolmV1AesSha2,
|
||||||
'room_id': roomId,
|
'room_id': roomId,
|
||||||
'forwarding_curve25519_key_chain': [client.identityKey],
|
'forwarding_curve25519_key_chain': [client.identityKey],
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ void main() {
|
||||||
final contentJson =
|
final contentJson =
|
||||||
'{"msgtype":"$msgtype","body":"$body","formatted_body":"$formatted_body","m.relates_to":{"m.in_reply_to":{"event_id":"\$1234:example.com"}}}';
|
'{"msgtype":"$msgtype","body":"$body","formatted_body":"$formatted_body","m.relates_to":{"m.in_reply_to":{"event_id":"\$1234:example.com"}}}';
|
||||||
|
|
||||||
var jsonObj = <String, dynamic>{
|
final jsonObj = <String, dynamic>{
|
||||||
'event_id': id,
|
'event_id': id,
|
||||||
'sender': senderID,
|
'sender': senderID,
|
||||||
'origin_server_ts': timestamp,
|
'origin_server_ts': timestamp,
|
||||||
|
|
@ -56,8 +56,8 @@ void main() {
|
||||||
'status': 2,
|
'status': 2,
|
||||||
'content': contentJson,
|
'content': contentJson,
|
||||||
};
|
};
|
||||||
var client = Client('testclient', httpClient: FakeMatrixApi());
|
final client = Client('testclient', httpClient: FakeMatrixApi());
|
||||||
var event = Event.fromJson(
|
final event = Event.fromJson(
|
||||||
jsonObj, Room(id: '!localpart:server.abc', client: client));
|
jsonObj, Room(id: '!localpart:server.abc', client: client));
|
||||||
|
|
||||||
test('setup', () async {
|
test('setup', () async {
|
||||||
|
|
@ -86,7 +86,7 @@ void main() {
|
||||||
expect(event.type, EventTypes.Message);
|
expect(event.type, EventTypes.Message);
|
||||||
expect(event.relationshipType, RelationshipTypes.reply);
|
expect(event.relationshipType, RelationshipTypes.reply);
|
||||||
jsonObj['state_key'] = '';
|
jsonObj['state_key'] = '';
|
||||||
var state = Event.fromJson(jsonObj, null);
|
final state = Event.fromJson(jsonObj, null);
|
||||||
expect(state.eventId, id);
|
expect(state.eventId, id);
|
||||||
expect(state.stateKey, '');
|
expect(state.stateKey, '');
|
||||||
expect(state.status, 2);
|
expect(state.status, 2);
|
||||||
|
|
@ -244,8 +244,8 @@ void main() {
|
||||||
'type': 'm.room.redaction',
|
'type': 'm.room.redaction',
|
||||||
'unsigned': {'age': 1234}
|
'unsigned': {'age': 1234}
|
||||||
};
|
};
|
||||||
var redactedBecause = Event.fromJson(redactionEventJson, room);
|
final redactedBecause = Event.fromJson(redactionEventJson, room);
|
||||||
var event = Event.fromJson(redactJsonObj, room);
|
final event = Event.fromJson(redactJsonObj, room);
|
||||||
event.setRedactionEvent(redactedBecause);
|
event.setRedactionEvent(redactedBecause);
|
||||||
expect(event.redacted, true);
|
expect(event.redacted, true);
|
||||||
expect(event.redactedBecause.toJson(), redactedBecause.toJson());
|
expect(event.redactedBecause.toJson(), redactedBecause.toJson());
|
||||||
|
|
@ -256,7 +256,7 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('remove', () async {
|
test('remove', () async {
|
||||||
var event = Event.fromJson(
|
final event = Event.fromJson(
|
||||||
jsonObj, Room(id: '1234', client: Client('testclient')));
|
jsonObj, Room(id: '1234', client: Client('testclient')));
|
||||||
final removed1 = await event.remove();
|
final removed1 = await event.remove();
|
||||||
event.status = 0;
|
event.status = 0;
|
||||||
|
|
@ -266,14 +266,14 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('sendAgain', () async {
|
test('sendAgain', () async {
|
||||||
var matrix = Client('testclient', httpClient: FakeMatrixApi());
|
final matrix = Client('testclient', httpClient: FakeMatrixApi());
|
||||||
await matrix.checkHomeserver('https://fakeserver.notexisting',
|
await matrix.checkHomeserver('https://fakeserver.notexisting',
|
||||||
checkWellKnown: false);
|
checkWellKnown: false);
|
||||||
await matrix.login(
|
await matrix.login(
|
||||||
identifier: AuthenticationUserIdentifier(user: 'test'),
|
identifier: AuthenticationUserIdentifier(user: 'test'),
|
||||||
password: '1234');
|
password: '1234');
|
||||||
|
|
||||||
var event = Event.fromJson(
|
final event = Event.fromJson(
|
||||||
jsonObj, Room(id: '!1234:example.com', client: matrix));
|
jsonObj, Room(id: '!1234:example.com', client: matrix));
|
||||||
final resp1 = await event.sendAgain();
|
final resp1 = await event.sendAgain();
|
||||||
event.status = -1;
|
event.status = -1;
|
||||||
|
|
@ -285,14 +285,14 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('requestKey', () async {
|
test('requestKey', () async {
|
||||||
var matrix = Client('testclient', httpClient: FakeMatrixApi());
|
final matrix = Client('testclient', httpClient: FakeMatrixApi());
|
||||||
await matrix.checkHomeserver('https://fakeserver.notexisting',
|
await matrix.checkHomeserver('https://fakeserver.notexisting',
|
||||||
checkWellKnown: false);
|
checkWellKnown: false);
|
||||||
await matrix.login(
|
await matrix.login(
|
||||||
identifier: AuthenticationUserIdentifier(user: 'test'),
|
identifier: AuthenticationUserIdentifier(user: 'test'),
|
||||||
password: '1234');
|
password: '1234');
|
||||||
|
|
||||||
var event = Event.fromJson(
|
final event = Event.fromJson(
|
||||||
jsonObj, Room(id: '!1234:example.com', client: matrix));
|
jsonObj, Room(id: '!1234:example.com', client: matrix));
|
||||||
String exception;
|
String exception;
|
||||||
try {
|
try {
|
||||||
|
|
@ -302,7 +302,7 @@ void main() {
|
||||||
}
|
}
|
||||||
expect(exception, 'Session key not requestable');
|
expect(exception, 'Session key not requestable');
|
||||||
|
|
||||||
var event2 = Event.fromJson({
|
final event2 = Event.fromJson({
|
||||||
'event_id': id,
|
'event_id': id,
|
||||||
'sender': senderID,
|
'sender': senderID,
|
||||||
'origin_server_ts': timestamp,
|
'origin_server_ts': timestamp,
|
||||||
|
|
@ -327,7 +327,7 @@ void main() {
|
||||||
});
|
});
|
||||||
test('requestKey', () async {
|
test('requestKey', () async {
|
||||||
jsonObj['state_key'] = '@alice:example.com';
|
jsonObj['state_key'] = '@alice:example.com';
|
||||||
var event = Event.fromJson(
|
final event = Event.fromJson(
|
||||||
jsonObj, Room(id: '!localpart:server.abc', client: client));
|
jsonObj, Room(id: '!localpart:server.abc', client: client));
|
||||||
expect(event.stateKeyUser.id, '@alice:example.com');
|
expect(event.stateKeyUser.id, '@alice:example.com');
|
||||||
});
|
});
|
||||||
|
|
@ -895,14 +895,14 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('aggregations', () {
|
test('aggregations', () {
|
||||||
var event = Event.fromJson({
|
final event = Event.fromJson({
|
||||||
'content': {
|
'content': {
|
||||||
'body': 'blah',
|
'body': 'blah',
|
||||||
'msgtype': 'm.text',
|
'msgtype': 'm.text',
|
||||||
},
|
},
|
||||||
'event_id': '\$source',
|
'event_id': '\$source',
|
||||||
}, null);
|
}, null);
|
||||||
var edit1 = Event.fromJson({
|
final edit1 = Event.fromJson({
|
||||||
'content': {
|
'content': {
|
||||||
'body': 'blah',
|
'body': 'blah',
|
||||||
'msgtype': 'm.text',
|
'msgtype': 'm.text',
|
||||||
|
|
@ -913,7 +913,7 @@ void main() {
|
||||||
},
|
},
|
||||||
'event_id': '\$edit1',
|
'event_id': '\$edit1',
|
||||||
}, null);
|
}, null);
|
||||||
var edit2 = Event.fromJson({
|
final edit2 = Event.fromJson({
|
||||||
'content': {
|
'content': {
|
||||||
'body': 'blah',
|
'body': 'blah',
|
||||||
'msgtype': 'm.text',
|
'msgtype': 'm.text',
|
||||||
|
|
@ -924,8 +924,9 @@ void main() {
|
||||||
},
|
},
|
||||||
'event_id': '\$edit2',
|
'event_id': '\$edit2',
|
||||||
}, null);
|
}, null);
|
||||||
var room = Room(client: client);
|
final room = Room(client: client);
|
||||||
var timeline = Timeline(events: <Event>[event, edit1, edit2], room: room);
|
final timeline =
|
||||||
|
Timeline(events: <Event>[event, edit1, edit2], room: room);
|
||||||
expect(event.hasAggregatedEvents(timeline, RelationshipTypes.edit), true);
|
expect(event.hasAggregatedEvents(timeline, RelationshipTypes.edit), true);
|
||||||
expect(event.aggregatedEvents(timeline, RelationshipTypes.edit),
|
expect(event.aggregatedEvents(timeline, RelationshipTypes.edit),
|
||||||
{edit1, edit2});
|
{edit1, edit2});
|
||||||
|
|
@ -955,7 +956,7 @@ void main() {
|
||||||
'sender': '@alice:example.org',
|
'sender': '@alice:example.org',
|
||||||
}, null);
|
}, null);
|
||||||
event.sortOrder = 0;
|
event.sortOrder = 0;
|
||||||
var edit1 = Event.fromJson({
|
final edit1 = Event.fromJson({
|
||||||
'type': EventTypes.Message,
|
'type': EventTypes.Message,
|
||||||
'content': {
|
'content': {
|
||||||
'body': '* edit 1',
|
'body': '* edit 1',
|
||||||
|
|
@ -973,7 +974,7 @@ void main() {
|
||||||
'sender': '@alice:example.org',
|
'sender': '@alice:example.org',
|
||||||
}, null);
|
}, null);
|
||||||
edit1.sortOrder = 1;
|
edit1.sortOrder = 1;
|
||||||
var edit2 = Event.fromJson({
|
final edit2 = Event.fromJson({
|
||||||
'type': EventTypes.Message,
|
'type': EventTypes.Message,
|
||||||
'content': {
|
'content': {
|
||||||
'body': '* edit 2',
|
'body': '* edit 2',
|
||||||
|
|
@ -991,7 +992,7 @@ void main() {
|
||||||
'sender': '@alice:example.org',
|
'sender': '@alice:example.org',
|
||||||
}, null);
|
}, null);
|
||||||
edit2.sortOrder = 2;
|
edit2.sortOrder = 2;
|
||||||
var edit3 = Event.fromJson({
|
final edit3 = Event.fromJson({
|
||||||
'type': EventTypes.Message,
|
'type': EventTypes.Message,
|
||||||
'content': {
|
'content': {
|
||||||
'body': '* edit 3',
|
'body': '* edit 3',
|
||||||
|
|
@ -1009,7 +1010,7 @@ void main() {
|
||||||
'sender': '@bob:example.org',
|
'sender': '@bob:example.org',
|
||||||
}, null);
|
}, null);
|
||||||
edit3.sortOrder = 3;
|
edit3.sortOrder = 3;
|
||||||
var room = Room(client: client);
|
final room = Room(client: client);
|
||||||
// no edits
|
// no edits
|
||||||
var displayEvent =
|
var displayEvent =
|
||||||
event.getDisplayEvent(Timeline(events: <Event>[event], room: room));
|
event.getDisplayEvent(Timeline(events: <Event>[event], room: room));
|
||||||
|
|
@ -1246,7 +1247,7 @@ void main() {
|
||||||
await client.checkHomeserver('https://fakeserver.notexisting',
|
await client.checkHomeserver('https://fakeserver.notexisting',
|
||||||
checkWellKnown: false);
|
checkWellKnown: false);
|
||||||
final room = Room(id: '!localpart:server.abc', client: await getClient());
|
final room = Room(id: '!localpart:server.abc', client: await getClient());
|
||||||
var event = Event.fromJson({
|
final event = Event.fromJson({
|
||||||
'type': EventTypes.Message,
|
'type': EventTypes.Message,
|
||||||
'content': {
|
'content': {
|
||||||
'body': 'image',
|
'body': 'image',
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ void main() {
|
||||||
group('Databse', () {
|
group('Databse', () {
|
||||||
Logs().level = Level.error;
|
Logs().level = Level.error;
|
||||||
var clientId = -1;
|
var clientId = -1;
|
||||||
var room = Room(id: '!room:blubb');
|
final room = Room(id: '!room:blubb');
|
||||||
test('setupDatabase', () async {
|
test('setupDatabase', () async {
|
||||||
final database = await getDatabase(null);
|
final database = await getDatabase(null);
|
||||||
clientId = await database.insertClient(
|
clientId = await database.insertClient(
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ void main() {
|
||||||
group('MxContent', () {
|
group('MxContent', () {
|
||||||
Logs().level = Level.error;
|
Logs().level = Level.error;
|
||||||
test('Formatting', () async {
|
test('Formatting', () async {
|
||||||
var client = Client('testclient', httpClient: FakeMatrixApi());
|
final client = Client('testclient', httpClient: FakeMatrixApi());
|
||||||
await client.checkHomeserver('https://fakeserver.notexisting',
|
await client.checkHomeserver('https://fakeserver.notexisting',
|
||||||
checkWellKnown: false);
|
checkWellKnown: false);
|
||||||
final mxc = 'mxc://exampleserver.abc/abcdefghijklmn';
|
final mxc = 'mxc://exampleserver.abc/abcdefghijklmn';
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ void main() {
|
||||||
'@charley:example.org'
|
'@charley:example.org'
|
||||||
];
|
];
|
||||||
|
|
||||||
var dbRoom = DbRoom(
|
final dbRoom = DbRoom(
|
||||||
clientId: 1,
|
clientId: 1,
|
||||||
roomId: id,
|
roomId: id,
|
||||||
membership: membership.toString().split('.').last,
|
membership: membership.toString().split('.').last,
|
||||||
|
|
@ -69,7 +69,7 @@ void main() {
|
||||||
heroes: heroes.join(','),
|
heroes: heroes.join(','),
|
||||||
);
|
);
|
||||||
|
|
||||||
var states = [
|
final states = [
|
||||||
DbRoomState(
|
DbRoomState(
|
||||||
clientId: 1,
|
clientId: 1,
|
||||||
eventId: '143273582443PhrSn:example.org',
|
eventId: '143273582443PhrSn:example.org',
|
||||||
|
|
@ -85,7 +85,7 @@ void main() {
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
|
|
||||||
var roomAccountData = [
|
final roomAccountData = [
|
||||||
DbRoomAccountData(
|
DbRoomAccountData(
|
||||||
clientId: 1,
|
clientId: 1,
|
||||||
type: 'com.test.foo',
|
type: 'com.test.foo',
|
||||||
|
|
@ -229,7 +229,7 @@ void main() {
|
||||||
test('requestParticipants', () async {
|
test('requestParticipants', () async {
|
||||||
final participants = await room.requestParticipants();
|
final participants = await room.requestParticipants();
|
||||||
expect(participants.length, 1);
|
expect(participants.length, 1);
|
||||||
var user = participants[0];
|
final user = participants[0];
|
||||||
expect(user.id, '@alice:example.org');
|
expect(user.id, '@alice:example.org');
|
||||||
expect(user.displayName, 'Alice Margatroid');
|
expect(user.displayName, 'Alice Margatroid');
|
||||||
expect(user.membership, Membership.join);
|
expect(user.membership, Membership.join);
|
||||||
|
|
|
||||||
|
|
@ -129,7 +129,7 @@ const updates = {
|
||||||
|
|
||||||
void testUpdates(bool Function(SyncUpdate s) test, Map<String, bool> expected) {
|
void testUpdates(bool Function(SyncUpdate s) test, Map<String, bool> expected) {
|
||||||
for (final update in updates.entries) {
|
for (final update in updates.entries) {
|
||||||
var sync = SyncUpdate.fromJson(update.value);
|
final sync = SyncUpdate.fromJson(update.value);
|
||||||
expect(test(sync), expected[update.key]);
|
expect(test(sync), expected[update.key]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -138,7 +138,7 @@ void main() {
|
||||||
group('Sync Filters', () {
|
group('Sync Filters', () {
|
||||||
Logs().level = Level.error;
|
Logs().level = Level.error;
|
||||||
test('room update', () {
|
test('room update', () {
|
||||||
var testFn = (SyncUpdate s) => s.hasRoomUpdate;
|
final testFn = (SyncUpdate s) => s.hasRoomUpdate;
|
||||||
final expected = {
|
final expected = {
|
||||||
'empty': false,
|
'empty': false,
|
||||||
'presence': false,
|
'presence': false,
|
||||||
|
|
@ -152,7 +152,7 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('presence update', () {
|
test('presence update', () {
|
||||||
var testFn = (SyncUpdate s) => s.hasPresenceUpdate;
|
final testFn = (SyncUpdate s) => s.hasPresenceUpdate;
|
||||||
final expected = {
|
final expected = {
|
||||||
'empty': false,
|
'empty': false,
|
||||||
'presence': true,
|
'presence': true,
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ void main() {
|
||||||
final roomID = '!1234:example.com';
|
final roomID = '!1234:example.com';
|
||||||
final testTimeStamp = DateTime.now().millisecondsSinceEpoch;
|
final testTimeStamp = DateTime.now().millisecondsSinceEpoch;
|
||||||
var updateCount = 0;
|
var updateCount = 0;
|
||||||
var insertList = <int>[];
|
final insertList = <int>[];
|
||||||
var olmEnabled = true;
|
var olmEnabled = true;
|
||||||
|
|
||||||
Client client;
|
Client client;
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ void main() {
|
||||||
group('UIA', () {
|
group('UIA', () {
|
||||||
Logs().level = Level.error;
|
Logs().level = Level.error;
|
||||||
test('it should work', () async {
|
test('it should work', () async {
|
||||||
var completed = <String>[];
|
final completed = <String>[];
|
||||||
var updated = 0;
|
var updated = 0;
|
||||||
var finished = false;
|
var finished = false;
|
||||||
final request = UiaRequest(
|
final request = UiaRequest(
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ void main() {
|
||||||
/// All Tests related to the Event
|
/// All Tests related to the Event
|
||||||
group('User', () {
|
group('User', () {
|
||||||
Logs().level = Level.error;
|
Logs().level = Level.error;
|
||||||
var client = Client('testclient', httpClient: FakeMatrixApi());
|
final client = Client('testclient', httpClient: FakeMatrixApi());
|
||||||
final user1 = User(
|
final user1 = User(
|
||||||
'@alice:example.com',
|
'@alice:example.com',
|
||||||
membership: 'join',
|
membership: 'join',
|
||||||
|
|
@ -65,7 +65,7 @@ void main() {
|
||||||
'state_key': id
|
'state_key': id
|
||||||
};
|
};
|
||||||
|
|
||||||
var user = Event.fromJson(jsonObj, null).asUser;
|
final user = Event.fromJson(jsonObj, null).asUser;
|
||||||
|
|
||||||
expect(user.id, id);
|
expect(user.id, id);
|
||||||
expect(user.membership, membership);
|
expect(user.membership, membership);
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ void test() async {
|
||||||
|
|
||||||
Logs().i('++++ (Alice) Leave all rooms ++++');
|
Logs().i('++++ (Alice) Leave all rooms ++++');
|
||||||
while (testClientA.rooms.isNotEmpty) {
|
while (testClientA.rooms.isNotEmpty) {
|
||||||
var room = testClientA.rooms.first;
|
final room = testClientA.rooms.first;
|
||||||
if (room.canonicalAlias?.isNotEmpty ?? false) {
|
if (room.canonicalAlias?.isNotEmpty ?? false) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -50,7 +50,7 @@ void test() async {
|
||||||
Logs().i('++++ (Bob) Leave all rooms ++++');
|
Logs().i('++++ (Bob) Leave all rooms ++++');
|
||||||
for (var i = 0; i < 3; i++) {
|
for (var i = 0; i < 3; i++) {
|
||||||
if (testClientB.rooms.isNotEmpty) {
|
if (testClientB.rooms.isNotEmpty) {
|
||||||
var room = testClientB.rooms.first;
|
final room = testClientB.rooms.first;
|
||||||
try {
|
try {
|
||||||
await room.leave();
|
await room.leave();
|
||||||
await room.forget();
|
await room.forget();
|
||||||
|
|
@ -77,12 +77,12 @@ void test() async {
|
||||||
Logs().i('++++ (Alice) Create room and invite Bob ++++');
|
Logs().i('++++ (Alice) Create room and invite Bob ++++');
|
||||||
await testClientA.createRoom(invite: [TestUser.username2]);
|
await testClientA.createRoom(invite: [TestUser.username2]);
|
||||||
await Future.delayed(Duration(seconds: 1));
|
await Future.delayed(Duration(seconds: 1));
|
||||||
var room = testClientA.rooms.first;
|
final room = testClientA.rooms.first;
|
||||||
assert(room != null);
|
assert(room != null);
|
||||||
final roomId = room.id;
|
final roomId = room.id;
|
||||||
|
|
||||||
Logs().i('++++ (Bob) Join room ++++');
|
Logs().i('++++ (Bob) Join room ++++');
|
||||||
var inviteRoom = testClientB.getRoomById(roomId);
|
final inviteRoom = testClientB.getRoomById(roomId);
|
||||||
await inviteRoom.join();
|
await inviteRoom.join();
|
||||||
await Future.delayed(Duration(seconds: 1));
|
await Future.delayed(Duration(seconds: 1));
|
||||||
assert(inviteRoom.membership == Membership.join);
|
assert(inviteRoom.membership == Membership.join);
|
||||||
|
|
@ -197,7 +197,8 @@ void test() async {
|
||||||
.outboundGroupSession
|
.outboundGroupSession
|
||||||
.session_id() ==
|
.session_id() ==
|
||||||
currentSessionIdA);
|
currentSessionIdA);
|
||||||
var inviteRoomOutboundGroupSession = inviteRoom.client.encryption.keyManager
|
final inviteRoomOutboundGroupSession = inviteRoom
|
||||||
|
.client.encryption.keyManager
|
||||||
.getOutboundGroupSession(inviteRoom.id);
|
.getOutboundGroupSession(inviteRoom.id);
|
||||||
|
|
||||||
assert(inviteRoomOutboundGroupSession != null);
|
assert(inviteRoomOutboundGroupSession != null);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue