fix: safe domains scan - use time.Time for timestamp columns instead of string
This commit is contained in:
parent
43199e52bc
commit
aa0e75d35f
|
|
@ -15,6 +15,11 @@ import (
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// formatTime formats a time.Time to a string for JSON output.
|
||||||
|
func formatTime(t time.Time) string {
|
||||||
|
return t.Format(time.RFC3339)
|
||||||
|
}
|
||||||
|
|
||||||
// LinkPreview represents the OG metadata extracted from a URL.
|
// LinkPreview represents the OG metadata extracted from a URL.
|
||||||
type LinkPreview struct {
|
type LinkPreview struct {
|
||||||
URL string `json:"link_preview_url"`
|
URL string `json:"link_preview_url"`
|
||||||
|
|
@ -325,13 +330,13 @@ func (s *LinkPreviewService) SaveLinkPreview(ctx context.Context, postID string,
|
||||||
|
|
||||||
// SafeDomain represents a row in the safe_domains table.
|
// SafeDomain represents a row in the safe_domains table.
|
||||||
type SafeDomain struct {
|
type SafeDomain struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
Domain string `json:"domain"`
|
Domain string `json:"domain"`
|
||||||
Category string `json:"category"`
|
Category string `json:"category"`
|
||||||
IsApproved bool `json:"is_approved"`
|
IsApproved bool `json:"is_approved"`
|
||||||
Notes *string `json:"notes"`
|
Notes *string `json:"notes"`
|
||||||
CreatedAt string `json:"created_at"`
|
CreatedAt time.Time `json:"created_at"`
|
||||||
UpdatedAt string `json:"updated_at"`
|
UpdatedAt time.Time `json:"updated_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListSafeDomains returns all safe domains, optionally filtered.
|
// ListSafeDomains returns all safe domains, optionally filtered.
|
||||||
|
|
@ -362,6 +367,7 @@ func (s *LinkPreviewService) ListSafeDomains(ctx context.Context, category strin
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
var d SafeDomain
|
var d SafeDomain
|
||||||
if err := rows.Scan(&d.ID, &d.Domain, &d.Category, &d.IsApproved, &d.Notes, &d.CreatedAt, &d.UpdatedAt); err != nil {
|
if err := rows.Scan(&d.ID, &d.Domain, &d.Category, &d.IsApproved, &d.Notes, &d.CreatedAt, &d.UpdatedAt); err != nil {
|
||||||
|
log.Warn().Err(err).Msg("Failed to scan safe domain row")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
domains = append(domains, d)
|
domains = append(domains, d)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue