fix(restore): properly decode notifications json data

Related to https://kolaente.dev/vikunja/api/issues/1199
This commit is contained in:
kolaente 2022-07-13 23:43:20 +02:00
parent ac92499b7d
commit 596d2bf676
No known key found for this signature in database
GPG key ID: F40E70337AB24C9B

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)
}