From dccf1a91e3aa94d1acf36cc1c5756ebfeffa3300 Mon Sep 17 00:00:00 2001 From: Sandro Date: Sun, 25 Oct 2026 01:59:23 +0200 Subject: [PATCH] feat(workspace): format origin callout date and time when converting thought to document --- internal/domain/models.go | 52 ++++++++++++++++++++++++++++++++++++++ internal/storage/sqlite.go | 13 +++++++++- 2 files changed, 64 insertions(+), 1 deletion(-) diff --git a/internal/domain/models.go b/internal/domain/models.go index ed838e8..c2f395c 100644 --- a/internal/domain/models.go +++ b/internal/domain/models.go @@ -40,6 +40,58 @@ func ExtractTags(content string) []string { return tags } +// FormatGermanDateTime formats an ISO-8601 string into "25. Okt. 2026 - 15:40 Uhr" +func FormatGermanDateTime(isoStr string) string { + if isoStr == "" { + return "" + } + var t time.Time + var err error + formats := []string{ + time.RFC3339Nano, + time.RFC3339, + "2006-01-02T15:04:05Z07:00", + "2006-01-02T15:04:05", + "2006-01-02 15:04:05", + "2006-01-02", + } + for _, f := range formats { + if parsed, parseErr := time.Parse(f, isoStr); parseErr == nil { + t = parsed + err = nil + break + } else { + err = parseErr + } + } + if err != nil { + return isoStr + } + + t = t.Local() + + germanMonths := map[time.Month]string{ + time.January: "Jan.", + time.February: "Feb.", + time.March: "März", + time.April: "Apr.", + time.May: "Mai", + time.June: "Juni", + time.July: "Juli", + time.August: "Aug.", + time.September: "Sept.", + time.October: "Okt.", + time.November: "Nov.", + time.December: "Dez.", + } + mStr := germanMonths[t.Month()] + if mStr == "" { + mStr = t.Format("Jan") + } + + return fmt.Sprintf("%d. %s %d - %02d:%02d Uhr", t.Day(), mStr, t.Year(), t.Hour(), t.Minute()) +} + type User struct { ID string `json:"id"` Email string `json:"email"` diff --git a/internal/storage/sqlite.go b/internal/storage/sqlite.go index 8c57d89..01ff5c9 100644 --- a/internal/storage/sqlite.go +++ b/internal/storage/sqlite.go @@ -812,6 +812,17 @@ func (s *Store) UpdateThoughtTriage(userID, thoughtID, action, convertTo, target title = title[:72] + "…" } blocks := make([]domain.DocumentBlock, 0) + formattedDate := domain.FormatGermanDateTime(thought.CreatedAt) + calloutText := "Ursprünglicher Gedanke aus deiner Inbox" + if formattedDate != "" { + calloutText += " vom " + formattedDate + } + blocks = append(blocks, domain.DocumentBlock{ + ID: domain.NewID("blk"), + Type: "callout", + Content: calloutText, + Level: 0, + }) if strings.TrimSpace(thought.Notes) != "" { blocks = append(blocks, domain.DocumentBlock{ ID: domain.NewID("blk"), @@ -831,7 +842,7 @@ func (s *Store) UpdateThoughtTriage(userID, thoughtID, action, convertTo, target }) } } - if len(blocks) == 0 { + if len(blocks) == 1 { blocks = append(blocks, domain.DocumentBlock{ ID: domain.NewID("blk"), Type: "bullet",