fix: room account data key/type returned encoded
We uri encode all hive keys. But in some cases we never decode them. This leads to fun issues like SSSS being unreadable after restart. fixes https://gitlab.com/famedly/company/frontend/famedlysdk/-/issues/179
This commit is contained in:
parent
33d31cecd1
commit
8b46fa3fc2
|
|
@ -282,8 +282,8 @@ class FamedlySdkHiveDatabase extends DatabaseApi {
|
|||
final accountData = <String, BasicEvent>{};
|
||||
for (final key in _accountDataBox.keys) {
|
||||
final raw = await _accountDataBox.get(key);
|
||||
accountData[key] = BasicEvent(
|
||||
type: key,
|
||||
accountData[key.toString().fromHiveKey] = BasicEvent(
|
||||
type: key.toString().fromHiveKey,
|
||||
content: convertToJson(raw),
|
||||
);
|
||||
}
|
||||
|
|
@ -1159,7 +1159,7 @@ class MultiKey {
|
|||
const MultiKey.byParts(this.parts);
|
||||
|
||||
MultiKey.fromString(String multiKeyString)
|
||||
: parts = multiKeyString.split('|');
|
||||
: parts = multiKeyString.split('|').map((s) => s.fromHiveKey).toList();
|
||||
|
||||
@override
|
||||
String toString() => parts.map((s) => s.toHiveKey).join('|');
|
||||
|
|
@ -1173,3 +1173,7 @@ extension HiveKeyExtension on String {
|
|||
? '$sigil${Uri.encodeComponent(localpart)}:${Uri.encodeComponent(domain)}'
|
||||
: Uri.encodeComponent(this);
|
||||
}
|
||||
|
||||
extension FromHiveKeyExtension on String {
|
||||
String get fromHiveKey => Uri.decodeComponent(this);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -155,6 +155,10 @@ void testDatabase(Future<DatabaseApi> futureDatabase, int clientId) {
|
|||
await database.storeAccountData(clientId, 'm.test', '{"foo":"bar"}');
|
||||
final events = await database.getAccountData(clientId);
|
||||
expect(events.values.single.type, 'm.test');
|
||||
|
||||
await database.storeAccountData(clientId, 'm.abc+de', '{"foo":"bar"}');
|
||||
final events2 = await database.getAccountData(clientId);
|
||||
expect(events2.values.any((element) => element.type == 'm.abc+de'), true);
|
||||
});
|
||||
test('storeEventUpdate', () async {
|
||||
await database.storeEventUpdate(
|
||||
|
|
|
|||
Loading…
Reference in New Issue