MM-33359 corrected unread replies update (#17068)

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
Eli Yukelzon
2021-03-09 16:10:47 +02:00
коммит произвёл GitHub
родитель 024bc97a5d
Коммит 90e7c5a852
12 изменённых файлов: 142 добавлений и 95 удалений

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

@@ -2378,7 +2378,7 @@ func (a *App) MarkChannelAsUnreadFromPost(postID string, userID string) (*model.
}
threadMembership, _ := a.Srv().Store.Thread().GetMembershipForUser(user.Id, threadId)
if threadMembership != nil {
if threadMembership != nil && threadMembership.Following {
channel, nErr := a.Srv().Store.Channel().Get(post.ChannelId, true)
if nErr != nil {
return nil, model.NewAppError("MarkChannelAsUnreadFromPost", "app.channel.update_last_viewed_at_post.app_error", nil, nErr.Error(), http.StatusInternalServerError)

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

@@ -183,16 +183,10 @@ func (a *App) SendNotifications(post *model.Post, team *model.Team, channel *mod
mac := make(chan *model.AppError, 1)
go func(userID string) {
defer close(mac)
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)
_, incrementMentions := mentions.Mentions[userID]
err := a.Srv().Store.Thread().MaintainMembership(userID, post.RootId, true, incrementMentions, *a.Config().ServiceSettings.ThreadAutoFollow, userID == post.UserId)
if err != nil {
mac <- model.NewAppError("SendNotifications", "app.channel.autofollow.app_error", nil, err.Error(), http.StatusInternalServerError)
return
}
@@ -439,7 +433,6 @@ func (a *App) SendNotifications(post *model.Post, team *model.Team, channel *mod
sendEvent = preference.Value == "on"
}
if sendEvent {
message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_THREAD_UPDATED, team.Id, "", uid, nil)
userThread, _ := a.Srv().Store.Thread().GetThreadForUser(uid, channel.TeamId, thread.PostId, true)
a.sanitizeProfiles(userThread.Participants, false)

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

@@ -458,12 +458,6 @@ func (a *App) handlePostEvents(post *model.Post, user *model.User, channel *mode
return err
}
if *a.Config().ServiceSettings.ThreadAutoFollow && post.RootId != "" {
if err := a.Srv().Store.Thread().CreateMembershipIfNeeded(post.UserId, post.RootId, true, false, true); err != nil {
return err
}
}
if post.Type != model.POST_AUTO_RESPONDER { // don't respond to an auto-responder
a.Srv().Go(func() {
_, err := a.SendAutoResponseIfNecessary(channel, user, post)

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

@@ -2403,7 +2403,7 @@ func (a *App) UpdateThreadsReadForUser(userID, teamID string) *model.AppError {
}
func (a *App) UpdateThreadFollowForUser(userID, teamID, threadID string, state bool) *model.AppError {
err := a.Srv().Store.Thread().CreateMembershipIfNeeded(userID, threadID, state, false, true)
err := a.Srv().Store.Thread().MaintainMembership(userID, threadID, state, false, true, false)
if err != nil {
return model.NewAppError("UpdateThreadFollowForUser", "app.user.update_thread_follow_for_user.app_error", nil, err.Error(), http.StatusInternalServerError)
}