From 596d2bf676c4ac06536004f396c7aad71be92420 Mon Sep 17 00:00:00 2001 From: kolaente Date: Wed, 13 Jul 2022 23:43:20 +0200 Subject: [PATCH] fix(restore): properly decode notifications json data Related to https://kolaente.dev/vikunja/api/issues/1199 --- pkg/modules/dump/restore.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pkg/modules/dump/restore.go b/pkg/modules/dump/restore.go index 47ce9b51..c7bfa9b9 100644 --- a/pkg/modules/dump/restore.go +++ b/pkg/modules/dump/restore.go @@ -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) }