mirror of
https://github.com/go-vikunja/vikunja.git
synced 2026-03-11 17:48:44 -05:00
feat: dispatch TaskOverdueEvent from overdue cron
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user