fix(restore): properly decode notifications json data

Related to vikunja/api#1199
This commit is contained in:
kolaente 2022-07-13 23:43:20 +02:00
parent ac92499b7d
commit 596d2bf676
Signed by untrusted user: konrad
GPG Key ID: F40E70337AB24C9B
1 changed files with 13 additions and 0 deletions

View File

@ -136,6 +136,19 @@ func Restore(filename string) error {
if err != nil {
return fmt.Errorf("could not read table %s: %w", table, err)
}
// FIXME: There has to be a general way to do this but this works for now.
if table == "notifications" {
for i := range content {
decoded, err := base64.StdEncoding.DecodeString(content[i]["notification"].(string))
if err != nil {
return fmt.Errorf("could not decode notification %s: %w", content[i]["notification"], err)
}
content[i]["notification"] = string(decoded)
}
}
if err := db.Restore(table, content); err != nil {
return fmt.Errorf("could not restore table data for table %s: %w", table, err)
}