From e0a7fb48b91175b590ac3c559627d4283a5bd108 Mon Sep 17 00:00:00 2001 From: "Erik Winter (aider)" Date: Mon, 2 Dec 2024 08:07:45 +0100 Subject: [PATCH] feat: Validate recurrence date before updating RecursNext --- sync/service/postgres.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sync/service/postgres.go b/sync/service/postgres.go index f64dbc3..f5eed03 100644 --- a/sync/service/postgres.go +++ b/sync/service/postgres.go @@ -150,6 +150,11 @@ func (p *Postgres) RecursNext(id string, date time.Time) error { return ErrNotARecurrer } + // Verify that the new date is actually a valid recurrence + if !recurrer.On(date) { + return fmt.Errorf("%w: date %v is not a valid recurrence", ErrPostgresFailure, date) + } + _, err = p.db.Exec(` UPDATE items SET recur_next = $1