MM-30970 Add Basic unreadMentions support for collapsed threads (#16407)

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
Eli Yukelzon
2020-12-01 17:20:23 +02:00
коммит произвёл GitHub
родитель 1bd7dc41bd
Коммит c2036f614e
14 изменённых файлов: 330 добавлений и 66 удалений

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

@@ -162,21 +162,27 @@ func (a *App) SendNotifications(post *model.Post, team *model.Team, channel *mod
mentionedUsersList := make([]string, 0, len(mentions.Mentions))
updateMentionChans := []chan *model.AppError{}
mentionAutofollowChans := []chan *model.AppError{}
threadParticipants := []string{post.UserId}
threadParticipants := map[string]bool{post.UserId: true}
if *a.Config().ServiceSettings.ThreadAutoFollow && post.RootId != "" {
if parentPostList != nil {
threadParticipants = append(threadParticipants, parentPostList.Posts[parentPostList.Order[0]].UserId)
threadParticipants[parentPostList.Posts[parentPostList.Order[0]].UserId] = true
}
for id := range mentions.Mentions {
threadParticipants = append(threadParticipants, id)
threadParticipants[id] = true
}
// for each mention, make sure to update thread autofollow
for _, id := range threadParticipants {
// for each mention, make sure to update thread autofollow (if enabled) and update increment mention count
for id := range threadParticipants {
mac := make(chan *model.AppError, 1)
go func(userId string) {
defer close(mac)
nErr := a.Srv().Store.Thread().CreateMembershipIfNeeded(userId, post.RootId, true)
incrementMentions := false
for mid := range mentions.Mentions {
if userId == mid {
incrementMentions = true
break
}
}
nErr := a.Srv().Store.Thread().CreateMembershipIfNeeded(userId, post.RootId, true, incrementMentions, *a.Config().ServiceSettings.ThreadAutoFollow)
if nErr != nil {
mac <- model.NewAppError("SendNotifications", "app.channel.autofollow.app_error", nil, nErr.Error(), http.StatusInternalServerError)
return