fix(subscriptions): ignore task subscription when the user is subscribed to the project
Resolves https://community.vikunja.io/t/e-mail-notification-twice/2740/12 Resolves https://github.com/go-vikunja/vikunja/issues/316 (cherry picked from commit efde364224cf744c448a5b8e069776f18652d314)
This commit is contained in:
parent
a253f76060
commit
1a131d79f9
@ -234,23 +234,12 @@ func GetSubscriptions(s *xorm.Session, entityType SubscriptionEntityType, entity
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the task does not have a subscription directly or from its project, get the one
|
projects, err := GetProjectsSimplByTaskIDs(s, entityIDs)
|
||||||
// from the parent and return it instead.
|
|
||||||
var taskIDsWithoutSubscription []int64
|
|
||||||
for _, eID := range entityIDs {
|
|
||||||
if _, has := subs[eID]; has {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
taskIDsWithoutSubscription = append(taskIDsWithoutSubscription, eID)
|
|
||||||
}
|
|
||||||
|
|
||||||
projects, err := GetProjectsSimplByTaskIDs(s, taskIDsWithoutSubscription)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks, err := GetTasksSimpleByIDs(s, taskIDsWithoutSubscription)
|
tasks, err := GetTasksSimpleByIDs(s, entityIDs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -261,9 +250,17 @@ func GetSubscriptions(s *xorm.Session, entityType SubscriptionEntityType, entity
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, task := range tasks {
|
for _, task := range tasks {
|
||||||
sub, has := projectSubscriptions[task.ProjectID]
|
// If a task is already subscribed through the parent project,
|
||||||
if has {
|
// remove the task subscription since that's a duplicate.
|
||||||
subs[task.ID] = sub
|
// But if the user is not subscribed to the task but a parent project is, add that to the subscriptions
|
||||||
|
psub, hasProjectSub := projectSubscriptions[task.ProjectID]
|
||||||
|
_, hasTaskSub := subs[task.ID]
|
||||||
|
if hasProjectSub && hasTaskSub {
|
||||||
|
delete(subs, task.ID)
|
||||||
|
}
|
||||||
|
|
||||||
|
if !hasTaskSub {
|
||||||
|
subs[task.ID] = psub
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user