MM-23896: Fix clearing of batched emails on user activity (#14340)
On user activity, we were clearing the job.pendingNotifications map. But we had already created a copy of the notifications slice while iterating the map. Therefore, if we pass the copied slice, it would still have the old notifications which were originally deleted. The unit tests would not catch this because it was testing the job.pendingNotifications map and not actually checking if the email handler was being called or not. We fix that now. Co-authored-by: mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
b29b70da09
Коммит
f79b7567b1
@@ -182,13 +182,13 @@ func (job *EmailBatchingJob) checkPendingNotifications(now time.Time, handler fu
|
||||
}
|
||||
}
|
||||
|
||||
// send the email notification if it's been long enough
|
||||
if now.Sub(time.Unix(batchStartTime/1000, 0)) > time.Duration(interval)*time.Second {
|
||||
// send the email notification if there are notifications to send AND it's been long enough
|
||||
if len(job.pendingNotifications[userId]) > 0 && now.Sub(time.Unix(batchStartTime/1000, 0)) > time.Duration(interval)*time.Second {
|
||||
job.server.Go(func(userId string, notifications []*batchedNotification) func() {
|
||||
return func() {
|
||||
handler(userId, notifications)
|
||||
}
|
||||
}(userId, notifications))
|
||||
}(userId, job.pendingNotifications[userId]))
|
||||
delete(job.pendingNotifications, userId)
|
||||
}
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user