Merge pull request #1973 from famedly/krille/fix-flutter-3-27-lints
refactor: Fix new lints from flutter 3.27
This commit is contained in:
commit
5d7b802027
|
|
@ -129,7 +129,7 @@ jobs:
|
|||
- name: Run tests
|
||||
run: |
|
||||
dart pub get
|
||||
dart test test/box_test.dart --platform chrome
|
||||
dart test test/box_test.dart --platform chrome --fail-fast
|
||||
|
||||
pub-dev-dry-run:
|
||||
runs-on: ubuntu-latest
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
flutter_version=3.24.3
|
||||
dart_version=3.5.3
|
||||
flutter_version=3.27.1
|
||||
dart_version=3.6.0
|
||||
|
|
|
|||
|
|
@ -193,7 +193,7 @@ class Encryption {
|
|||
}
|
||||
}
|
||||
|
||||
Event decryptRoomEventSync(String roomId, Event event) {
|
||||
Event decryptRoomEventSync(Event event) {
|
||||
if (event.type != EventTypes.Encrypted || event.redacted) {
|
||||
return event;
|
||||
}
|
||||
|
|
@ -214,7 +214,7 @@ class Encryption {
|
|||
}
|
||||
|
||||
final inboundGroupSession =
|
||||
keyManager.getInboundGroupSession(roomId, sessionId);
|
||||
keyManager.getInboundGroupSession(event.room.id, sessionId);
|
||||
if (!(inboundGroupSession?.isValid ?? false)) {
|
||||
canRequestSession = true;
|
||||
throw DecryptException(DecryptException.unknownSession);
|
||||
|
|
@ -249,7 +249,7 @@ class Encryption {
|
|||
// ignore: discarded_futures
|
||||
?.updateInboundGroupSessionIndexes(
|
||||
json.encode(inboundGroupSession.indexes),
|
||||
roomId,
|
||||
event.room.id,
|
||||
sessionId,
|
||||
)
|
||||
// ignore: discarded_futures
|
||||
|
|
@ -260,14 +260,16 @@ class Encryption {
|
|||
// alright, if this was actually by our own outbound group session, we might as well clear it
|
||||
if (exception.toString() != DecryptException.unknownSession &&
|
||||
(keyManager
|
||||
.getOutboundGroupSession(roomId)
|
||||
.getOutboundGroupSession(event.room.id)
|
||||
?.outboundGroupSession
|
||||
?.session_id() ??
|
||||
'') ==
|
||||
content.sessionId) {
|
||||
runInRoot(
|
||||
() async =>
|
||||
keyManager.clearOrUseOutboundGroupSession(roomId, wipe: true),
|
||||
() async => keyManager.clearOrUseOutboundGroupSession(
|
||||
event.room.id,
|
||||
wipe: true,
|
||||
),
|
||||
);
|
||||
}
|
||||
if (canRequestSession) {
|
||||
|
|
@ -308,7 +310,6 @@ class Encryption {
|
|||
}
|
||||
|
||||
Future<Event> decryptRoomEvent(
|
||||
String roomId,
|
||||
Event event, {
|
||||
bool store = false,
|
||||
EventUpdateType updateType = EventUpdateType.timeline,
|
||||
|
|
@ -323,22 +324,22 @@ class Encryption {
|
|||
sessionId != null &&
|
||||
!(keyManager
|
||||
.getInboundGroupSession(
|
||||
roomId,
|
||||
event.room.id,
|
||||
sessionId,
|
||||
)
|
||||
?.isValid ??
|
||||
false)) {
|
||||
await keyManager.loadInboundGroupSession(
|
||||
roomId,
|
||||
event.room.id,
|
||||
sessionId,
|
||||
);
|
||||
}
|
||||
event = decryptRoomEventSync(roomId, event);
|
||||
event = decryptRoomEventSync(event);
|
||||
if (event.type == EventTypes.Encrypted &&
|
||||
event.content['can_request_session'] == true &&
|
||||
sessionId != null) {
|
||||
keyManager.maybeAutoRequest(
|
||||
roomId,
|
||||
event.room.id,
|
||||
sessionId,
|
||||
content.senderKey,
|
||||
);
|
||||
|
|
@ -350,7 +351,7 @@ class Encryption {
|
|||
await client.database?.storeEventUpdate(
|
||||
EventUpdate(
|
||||
content: event.toJson(),
|
||||
roomID: roomId,
|
||||
roomID: event.room.id,
|
||||
type: updateType,
|
||||
),
|
||||
client,
|
||||
|
|
|
|||
|
|
@ -192,7 +192,7 @@ class KeyManager {
|
|||
if (event != null &&
|
||||
event.type == EventTypes.Encrypted &&
|
||||
event.content['session_id'] == sessionId) {
|
||||
final decrypted = encryption.decryptRoomEventSync(roomId, event);
|
||||
final decrypted = encryption.decryptRoomEventSync(event);
|
||||
if (decrypted.type != EventTypes.Encrypted) {
|
||||
// Update the last event in memory first
|
||||
room.lastEvent = decrypted;
|
||||
|
|
|
|||
|
|
@ -27,7 +27,9 @@ extension JsonSignatureCheckExtension on Map<String, dynamic> {
|
|||
final signatures = this['signatures'];
|
||||
if (signatures == null ||
|
||||
signatures is! Map<String, dynamic> ||
|
||||
!signatures.containsKey(userId)) return false;
|
||||
!signatures.containsKey(userId)) {
|
||||
return false;
|
||||
}
|
||||
remove('unsigned');
|
||||
remove('signatures');
|
||||
if (!signatures[userId].containsKey('ed25519:$deviceId')) return false;
|
||||
|
|
|
|||
|
|
@ -54,7 +54,9 @@ extension DehydratedDeviceHandler on Client {
|
|||
// Only handle devices we understand
|
||||
// In the future we might want to migrate to a newer format here
|
||||
if (device.deviceData?.tryGet<String>('algorithm') !=
|
||||
_dehydratedDeviceAlgorithm) return;
|
||||
_dehydratedDeviceAlgorithm) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Verify that the device is cross-signed
|
||||
final dehydratedDeviceIdentity =
|
||||
|
|
|
|||
|
|
@ -1243,10 +1243,7 @@ class Client extends MatrixApi {
|
|||
if (archivedRoom.encrypted && archivedRoom.client.encryptionEnabled) {
|
||||
if (timeline.events[i].type == EventTypes.Encrypted) {
|
||||
await archivedRoom.client.encryption!
|
||||
.decryptRoomEvent(
|
||||
archivedRoom.id,
|
||||
timeline.events[i],
|
||||
)
|
||||
.decryptRoomEvent(timeline.events[i])
|
||||
.then(
|
||||
(decrypted) => timeline.events[i] = decrypted,
|
||||
);
|
||||
|
|
@ -1880,11 +1877,11 @@ class Client extends MatrixApi {
|
|||
|
||||
final encryption = this.encryption;
|
||||
if (event.type == EventTypes.Encrypted && encryption != null) {
|
||||
var decrypted = await encryption.decryptRoomEvent(roomId, event);
|
||||
var decrypted = await encryption.decryptRoomEvent(event);
|
||||
if (decrypted.messageType == MessageTypes.BadEncrypted &&
|
||||
prevBatch != null) {
|
||||
await oneShotSync();
|
||||
decrypted = await encryption.decryptRoomEvent(roomId, event);
|
||||
decrypted = await encryption.decryptRoomEvent(event);
|
||||
}
|
||||
event = decrypted;
|
||||
}
|
||||
|
|
@ -2567,7 +2564,9 @@ class Client extends MatrixApi {
|
|||
if (event.event.roomID != roomId) continue;
|
||||
if (!sessionIds.contains(
|
||||
event.event.content['content']?['session_id'],
|
||||
)) continue;
|
||||
)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final decryptedEvent = await event.event.decrypt(room);
|
||||
if (decryptedEvent.content.tryGet<String>('type') !=
|
||||
|
|
|
|||
|
|
@ -115,7 +115,9 @@ class ReceiptEventContent {
|
|||
|
||||
if (userId is! String ||
|
||||
!userId.isValidMatrixId ||
|
||||
receiptContent is! Map) continue;
|
||||
receiptContent is! Map) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final ts = receiptContent['ts'];
|
||||
final threadId = receiptContent['thread_id'];
|
||||
|
|
|
|||
|
|
@ -518,7 +518,9 @@ class Room {
|
|||
// There is no known event or the last event is only a state fallback event,
|
||||
// we assume there is no new messages.
|
||||
if (lastEvent == null ||
|
||||
!client.roomPreviewLastEvents.contains(lastEvent.type)) return false;
|
||||
!client.roomPreviewLastEvents.contains(lastEvent.type)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Read marker is on the last event so no new messages.
|
||||
if (lastEvent.receipts
|
||||
|
|
@ -1458,10 +1460,7 @@ class Room {
|
|||
for (var i = 0; i < events.length; i++) {
|
||||
if (events[i].type == EventTypes.Encrypted &&
|
||||
events[i].content['can_request_session'] == true) {
|
||||
events[i] = await client.encryption!.decryptRoomEvent(
|
||||
id,
|
||||
events[i],
|
||||
);
|
||||
events[i] = await client.encryption!.decryptRoomEvent(events[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1527,10 +1526,7 @@ class Room {
|
|||
// Try to decrypt encrypted events but don't update the database.
|
||||
if (encrypted && client.encryptionEnabled) {
|
||||
if (events[i].type == EventTypes.Encrypted) {
|
||||
events[i] = await client.encryption!.decryptRoomEvent(
|
||||
id,
|
||||
events[i],
|
||||
);
|
||||
events[i] = await client.encryption!.decryptRoomEvent(events[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1574,7 +1570,6 @@ class Room {
|
|||
// for the fragmented timeline, we don't cache the decrypted
|
||||
//message in the database
|
||||
chunk.events[i] = await client.encryption!.decryptRoomEvent(
|
||||
id,
|
||||
chunk.events[i],
|
||||
);
|
||||
} else if (client.database != null) {
|
||||
|
|
@ -1583,7 +1578,6 @@ class Room {
|
|||
for (var i = 0; i < chunk.events.length; i++) {
|
||||
if (chunk.events[i].content['can_request_session'] == true) {
|
||||
chunk.events[i] = await client.encryption!.decryptRoomEvent(
|
||||
id,
|
||||
chunk.events[i],
|
||||
store: !isArchived,
|
||||
updateType: EventUpdateType.history,
|
||||
|
|
@ -1911,10 +1905,7 @@ class Room {
|
|||
final event = Event.fromMatrixEvent(matrixEvent, this);
|
||||
if (event.type == EventTypes.Encrypted && client.encryptionEnabled) {
|
||||
// attempt decryption
|
||||
return await client.encryption?.decryptRoomEvent(
|
||||
id,
|
||||
event,
|
||||
);
|
||||
return await client.encryption?.decryptRoomEvent(event);
|
||||
}
|
||||
return event;
|
||||
} on MatrixException catch (err) {
|
||||
|
|
|
|||
|
|
@ -263,7 +263,9 @@ class Timeline {
|
|||
|
||||
if (!allowNewEvent) {
|
||||
if (resp.start == resp.end ||
|
||||
(resp.end == null && direction == Direction.f)) allowNewEvent = true;
|
||||
(resp.end == null && direction == Direction.f)) {
|
||||
allowNewEvent = true;
|
||||
}
|
||||
|
||||
if (allowNewEvent) {
|
||||
Logs().d('We now allow sync update into the timeline.');
|
||||
|
|
@ -279,7 +281,6 @@ class Timeline {
|
|||
for (var i = 0; i < newEvents.length; i++) {
|
||||
if (newEvents[i].type == EventTypes.Encrypted) {
|
||||
newEvents[i] = await room.client.encryption!.decryptRoomEvent(
|
||||
room.id,
|
||||
newEvents[i],
|
||||
);
|
||||
}
|
||||
|
|
@ -388,7 +389,6 @@ class Timeline {
|
|||
events[i].messageType == MessageTypes.BadEncrypted &&
|
||||
events[i].content['session_id'] == sessionId) {
|
||||
events[i] = await encryption.decryptRoomEvent(
|
||||
room.id,
|
||||
events[i],
|
||||
store: true,
|
||||
updateType: EventUpdateType.history,
|
||||
|
|
@ -566,7 +566,9 @@ class Timeline {
|
|||
events.indexWhere(
|
||||
(e) => e.eventId == eventUpdate.content['event_id'],
|
||||
) !=
|
||||
-1) return;
|
||||
-1) {
|
||||
return;
|
||||
}
|
||||
var index = events.length;
|
||||
if (eventUpdate.type == EventUpdateType.history) {
|
||||
events.add(newEvent);
|
||||
|
|
@ -703,7 +705,7 @@ class Timeline {
|
|||
for (final matrixEvent in resp.chunk) {
|
||||
var event = Event.fromMatrixEvent(matrixEvent, room);
|
||||
if (event.type == EventTypes.Encrypted && encryption != null) {
|
||||
event = await encryption.decryptRoomEvent(room.id, event);
|
||||
event = await encryption.decryptRoomEvent(event);
|
||||
if (event.type == EventTypes.Encrypted &&
|
||||
event.messageType == MessageTypes.BadEncrypted &&
|
||||
event.content['can_request_session'] == true) {
|
||||
|
|
|
|||
|
|
@ -203,7 +203,6 @@ abstract class EventLocalizations {
|
|||
case RoomMemberChangeType.knock:
|
||||
return i18n.hasKnocked(targetName);
|
||||
case RoomMemberChangeType.other:
|
||||
default:
|
||||
return userIsTarget
|
||||
? i18n.youJoinedTheChat
|
||||
: i18n.joinedTheChat(targetName);
|
||||
|
|
|
|||
|
|
@ -68,7 +68,6 @@ class EventUpdate {
|
|||
}
|
||||
try {
|
||||
final decrpytedEvent = await encryption.decryptRoomEvent(
|
||||
room.id,
|
||||
Event.fromJson(content, room),
|
||||
store: store,
|
||||
updateType: type,
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ class PushNotification {
|
|||
});
|
||||
|
||||
/// Generate a Push Notification object from JSON. It also supports a
|
||||
/// <String, String> map which usually comes from Firebase Cloud Messaging.
|
||||
/// `map<String, String>` which usually comes from Firebase Cloud Messaging.
|
||||
factory PushNotification.fromJson(Map<String, dynamic> json) =>
|
||||
PushNotification(
|
||||
content: json['content'] is Map
|
||||
|
|
|
|||
|
|
@ -153,7 +153,6 @@ class _MemberCountCondition {
|
|||
case _CountComparisonOp.lt:
|
||||
return memberCount < count;
|
||||
case _CountComparisonOp.eq:
|
||||
default:
|
||||
return memberCount == count;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,11 +13,10 @@ bool isVersionGreaterThanOrEqualTo(String version, String target) {
|
|||
}
|
||||
|
||||
return true;
|
||||
} catch (e, s) {
|
||||
Logs().e(
|
||||
} catch (e) {
|
||||
Logs().w(
|
||||
'[_isVersionGreaterThanOrEqualTo] Failed to parse version $version',
|
||||
e,
|
||||
s,
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -650,7 +650,6 @@ class MeshBackend extends CallBackend {
|
|||
await call.setLocalVideoMuted(muted);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1016,7 +1016,9 @@ class CallSession {
|
|||
// when a call crash and this call is already terminated the currentCId is null.
|
||||
// So don't return bc the hangup or reject will not proceed anymore.
|
||||
if (voip.currentCID != null &&
|
||||
voip.currentCID != VoipId(roomId: room.id, callId: callId)) return;
|
||||
voip.currentCID != VoipId(roomId: room.id, callId: callId)) {
|
||||
return;
|
||||
}
|
||||
voip.currentCID = null;
|
||||
voip.incomingCallRoomId.removeWhere((key, value) => value == callId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ if [ -n "$NO_OLM" ]; then
|
|||
tagFlag="-x olm"
|
||||
fi
|
||||
|
||||
dart test --concurrency=$thread_count --coverage=coverage_dir $tagFlag
|
||||
dart test --concurrency=$thread_count --coverage=coverage_dir $tagFlag --fail-fast
|
||||
TEST_CODE=$?
|
||||
|
||||
# lets you do more stuff like reporton
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ void main() {
|
|||
});
|
||||
|
||||
test('Login', () async {
|
||||
matrix = Client(
|
||||
final matrix = Client(
|
||||
'testclient',
|
||||
httpClient: FakeMatrixApi(),
|
||||
databaseBuilder: getDatabase,
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ void main() {
|
|||
senderId: client.userID!,
|
||||
);
|
||||
final decryptedEvent =
|
||||
await client.encryption!.decryptRoomEvent(roomId, encryptedEvent);
|
||||
await client.encryption!.decryptRoomEvent(encryptedEvent);
|
||||
expect(decryptedEvent.type, 'm.room.message');
|
||||
expect(decryptedEvent.content['msgtype'], 'm.text');
|
||||
expect(decryptedEvent.content['text'], 'Hello foxies!');
|
||||
|
|
@ -80,7 +80,7 @@ void main() {
|
|||
senderId: client.userID!,
|
||||
);
|
||||
final decryptedEvent =
|
||||
await client.encryption!.decryptRoomEvent(roomId, encryptedEvent);
|
||||
await client.encryption!.decryptRoomEvent(encryptedEvent);
|
||||
expect(decryptedEvent.type, 'm.room.message');
|
||||
expect(decryptedEvent.content['msgtype'], 'm.text');
|
||||
expect(decryptedEvent.content['text'], 'Hello foxies!');
|
||||
|
|
@ -98,12 +98,11 @@ void main() {
|
|||
senderId: '@alice:example.com',
|
||||
);
|
||||
final decryptedEvent =
|
||||
await client.encryption!.decryptRoomEvent(roomId, encryptedEvent);
|
||||
await client.encryption!.decryptRoomEvent(encryptedEvent);
|
||||
expect(decryptedEvent.type, 'm.room.message');
|
||||
expect(decryptedEvent.content['msgtype'], 'm.text');
|
||||
expect(decryptedEvent.content['text'], 'Hello foxies!');
|
||||
await client.encryption!
|
||||
.decryptRoomEvent(roomId, encryptedEvent, store: true);
|
||||
await client.encryption!.decryptRoomEvent(encryptedEvent, store: true);
|
||||
});
|
||||
|
||||
test('dispose client', () async {
|
||||
|
|
|
|||
Loading…
Reference in New Issue