fix(assignees): prevent double notifications for assignees

This commit is contained in:
kolaente 2024-01-28 13:11:50 +01:00
parent e03920b84a
commit b2970c6c04
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
1 changed files with 9 additions and 0 deletions

View File

@ -291,11 +291,18 @@ func (s *SendTaskAssignedNotification) Handle(msg *message.Message) (err error)
return err
}
notifiedUsers := make(map[int64]bool)
for _, subscriber := range subscribers {
if subscriber.UserID == event.Doer.ID {
continue
}
if notifiedUsers[subscriber.UserID] {
// Users may be subscribed to the task and the project itself, which leads to double notifications
continue
}
n := &TaskAssignedNotification{
Doer: event.Doer,
Task: &task,
@ -306,6 +313,8 @@ func (s *SendTaskAssignedNotification) Handle(msg *message.Message) (err error)
if err != nil {
return
}
notifiedUsers[subscriber.UserID] = true
}
return nil