Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: No roomId in BasicRoomEvent stores roomaccountdata silently wrong #1997

Merged
merged 1 commit into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/src/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2670,7 +2670,7 @@ class Client extends MatrixApi {
final accountData = syncRoomUpdate.accountData;
if (accountData != null && accountData.isNotEmpty) {
for (final event in accountData) {
await database?.storeRoomAccountData(event);
await database?.storeRoomAccountData(room.id, event);
room.roomAccountData[event.type] = event;
}
}
Expand Down Expand Up @@ -2739,7 +2739,7 @@ class Client extends MatrixApi {
roomId: room.id,
content: receiptStateContent.toJson(),
);
await database?.storeRoomAccountData(event);
await database?.storeRoomAccountData(room.id, event);
room.roomAccountData[event.type] = event;
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/src/database/database_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ abstract class DatabaseApi {

Future storeAccountData(String type, Map<String, Object?> content);

Future storeRoomAccountData(BasicRoomEvent event);
Future storeRoomAccountData(String roomId, BasicRoomEvent event);

Future<Map<String, DeviceKeysList>> getUserDeviceKeys(Client client);

Expand Down
4 changes: 2 additions & 2 deletions lib/src/database/hive_collections_database.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1096,9 +1096,9 @@ class HiveCollectionsDatabase extends DatabaseApi {
}

@override
Future<void> storeRoomAccountData(BasicRoomEvent event) async {
Future<void> storeRoomAccountData(String roomId, BasicRoomEvent event) async {
await _roomAccountDataBox.put(
TupleKey(event.roomId ?? '', event.type).toString(),
TupleKey(roomId, event.type).toString(),
copyMap(event.toJson()),
);
return;
Expand Down
4 changes: 2 additions & 2 deletions lib/src/database/matrix_sdk_database.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1084,9 +1084,9 @@ class MatrixSdkDatabase extends DatabaseApi with DatabaseFileStorage {
}

@override
Future<void> storeRoomAccountData(BasicRoomEvent event) async {
Future<void> storeRoomAccountData(String roomId, BasicRoomEvent event) async {
await _roomAccountDataBox.put(
TupleKey(event.roomId ?? '', event.type).toString(),
TupleKey(roomId, event.type).toString(),
event.toJson(),
);
return;
Expand Down
1 change: 1 addition & 0 deletions test/database_api_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ void main() {
);

await database.storeRoomAccountData(
roomid,
BasicRoomEvent(
content: {'foo': 'bar'},
type: 'm.test',
Expand Down
Loading