From 313b99e2963d7bcf50571c602b790597f6561a56 Mon Sep 17 00:00:00 2001 From: kolaente Date: Wed, 4 Sep 2024 22:11:07 +0200 Subject: [PATCH] fix(reminders): notify subscribed users as well Resolves https://community.vikunja.io/t/no-reminder-notification-by-e-mail-from-my-colleague/2779 (cherry picked from commit 34ac29fcceec0b9f5f0c3c9fb22c015858f357d5) --- pkg/models/task_reminder.go | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/pkg/models/task_reminder.go b/pkg/models/task_reminder.go index bc1fd0208..336e82a11 100644 --- a/pkg/models/task_reminder.go +++ b/pkg/models/task_reminder.go @@ -124,6 +124,39 @@ func getTaskUsersForTasks(s *xorm.Session, taskIDs []int64, cond builder.Cond) ( }) } + subscriptions, err := GetSubscriptionsForEntities(s, SubscriptionEntityTask, taskIDs) + if err != nil { + return nil, err + } + + subscriberIDs := []int64{} + for _, subs := range subscriptions { + for _, sub := range subs { + subscriberIDs = append(subscriberIDs, sub.UserID) + } + } + + subscribers, err := user.GetUsersByCond(s, builder.And( + builder.In("id", subscriberIDs), + cond, + )) + if err != nil { + return nil, err + } + + for taskID, subs := range subscriptions { + for _, sub := range subs { + u, has := subscribers[sub.UserID] + if !has { + continue + } + taskUsers = append(taskUsers, &taskUser{ + Task: taskMap[taskID], + User: u, + }) + } + } + return }