Skip to content

📚 The open-source, offline-first Notion, Obsidian & Confluence alternative. Advanced Markdown, multi-tenant teams, OIDC/SSO, and local S3 backups. Deploy in one command.

Fix snowflake api json

Smaug673909769435b0db
diff --git a/backend/types/Snowflake.go b/backend/types/Snowflake.go
index 20559fd2..ea668f14 100644
--- a/backend/types/Snowflake.go
+++ b/backend/types/Snowflake.go
@@ -3,6 +3,7 @@ package types
import (
"encoding/json"
"strconv"
+ "strings"
)
type Snowflake uint64
@@ -11,3 +12,14 @@ func (s Snowflake) MarshalJSON() ([]byte, error) {
// Renvoie l'ID entre guillemets, pour JSON
return json.Marshal(strconv.FormatUint(uint64(s), 10))
}
+
+// UnmarshalJSON : décode un string JSON en Snowflake
+func (s *Snowflake) UnmarshalJSON(b []byte) error {
+ str := strings.Trim(string(b), `"`)
+ val, err := strconv.ParseUint(str, 10, 64)
+ if err != nil {
+ return err
+ }
+ *s = Snowflake(val)
+ return nil
+}