Merge branch 'soru/fix-account-data' into 'master'

Hotfix: account_data stored incorrectly in the database

See merge request famedly/famedlysdk!372
This commit is contained in:
Sorunome 2020-06-26 16:53:48 +00:00
commit 28fd207f2a
2 changed files with 9 additions and 2 deletions

View file

@ -752,7 +752,7 @@ class Client {
await database.storeAccountData( await database.storeAccountData(
id, id,
newAccountData.type, newAccountData.type,
jsonEncode(newAccountData.toJson()), jsonEncode(newAccountData.content),
); );
} }
accountData[newAccountData.type] = newAccountData; accountData[newAccountData.type] = newAccountData;

View file

@ -176,7 +176,14 @@ class Database extends _$Database {
final newAccountData = <String, api.BasicEvent>{}; final newAccountData = <String, api.BasicEvent>{};
final rawAccountData = await getAllAccountData(clientId).get(); final rawAccountData = await getAllAccountData(clientId).get();
for (final d in rawAccountData) { 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( newAccountData[d.type] = api.BasicEvent(
content: content, content: content,
type: d.type, type: d.type,