From 163cbdb923aaebbc262664aa840f066015d34f8b Mon Sep 17 00:00:00 2001 From: Sorunome Date: Fri, 26 Jun 2020 18:46:54 +0200 Subject: [PATCH] Hotfix: account_data stored incorrectly in the database --- lib/src/client.dart | 2 +- lib/src/database/database.dart | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/src/client.dart b/lib/src/client.dart index 0de7da3..6c7b96d 100644 --- a/lib/src/client.dart +++ b/lib/src/client.dart @@ -752,7 +752,7 @@ class Client { await database.storeAccountData( id, newAccountData.type, - jsonEncode(newAccountData.toJson()), + jsonEncode(newAccountData.content), ); } accountData[newAccountData.type] = newAccountData; diff --git a/lib/src/database/database.dart b/lib/src/database/database.dart index b033a27..d860a97 100644 --- a/lib/src/database/database.dart +++ b/lib/src/database/database.dart @@ -176,7 +176,14 @@ class Database extends _$Database { final newAccountData = {}; final rawAccountData = await getAllAccountData(clientId).get(); for (final d in rawAccountData) { - final content = sdk.Event.getMapFromPayload(d.content); + var content = sdk.Event.getMapFromPayload(d.content); + // there was a bug where it stored the entire event, not just the content + // in the databse. This is the temporary fix for those affected by the bug + if (content['content'] is Map && content['type'] is String) { + content = content['content']; + // and save + await storeAccountData(clientId, d.type, jsonEncode(content)); + } newAccountData[d.type] = api.BasicEvent( content: content, type: d.type,