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 untrusted user: konrad
GPG Key ID: F40E70337AB24C9B

View File

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