feat: dispatch TaskOverdueEvent from overdue cron

This commit is contained in:
kolaente
2026-02-24 19:50:42 +01:00
parent 626e731ae4
commit 54aacd3707

View File

@@ -22,6 +22,7 @@ import (
"code.vikunja.io/api/pkg/config"
"code.vikunja.io/api/pkg/cron"
"code.vikunja.io/api/pkg/db"
"code.vikunja.io/api/pkg/events"
"code.vikunja.io/api/pkg/log"
"code.vikunja.io/api/pkg/notifications"
"code.vikunja.io/api/pkg/user"
@@ -172,6 +173,25 @@ func RegisterOverdueReminderCron() {
log.Debugf("[Undone Overdue Tasks Reminder] Sent reminder email for %d tasks to user %d", len(ut.tasks), ut.user.ID)
}
// Dispatch webhook events, deduplicated by task ID across all users
dispatchedTasks := make(map[int64]bool)
for _, ut := range uts {
for _, t := range ut.tasks {
if dispatchedTasks[t.ID] {
continue
}
dispatchedTasks[t.ID] = true
err = events.Dispatch(&TaskOverdueEvent{
Task: t,
Project: projects[t.ProjectID],
})
if err != nil {
log.Errorf("[Undone Overdue Tasks Reminder] Could not dispatch overdue event for task %d: %s", t.ID, err)
return
}
}
}
})
if err != nil {
log.Fatalf("Could not register undone overdue tasks reminder cron: %s", err)