Fixes race condition in notification.go (#18226)

* Fixes race condition in notification.go

Appending is not thread safe, this commit makes followers a map
so we can add new followers from autofollow, and then adds those again
to followers.

* Fixes race condition
Этот коммит содержится в:
Kyriakos Z
2021-08-19 22:20:26 +03:00
коммит произвёл GitHub
родитель 95cea03704
Коммит ab0e82d656

Просмотреть файл

@@ -255,12 +255,12 @@ func (a *App) SendNotifications(post *model.Post, team *model.Team, channel *mod
return
}
followersMutex.Lock()
// add new followers to existing followers
if threadMembership.Following && !followers.Contains(userID) {
followersMutex.Lock()
followers = append(followers, userID)
followersMutex.Unlock()
}
followersMutex.Unlock()
membershipsMutex.Lock()
participantMemberships[userID] = threadMembership