MM-35128 CRT: Global Threads item should not be affected by 'mark as unread' in channel (#17505)

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
Eli Yukelzon
2021-04-27 16:56:06 +03:00
коммит произвёл GitHub
родитель 89281c00b1
Коммит 3d6e69b002
2 изменённых файлов: 30 добавлений и 28 удалений

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

@@ -2389,9 +2389,9 @@ func (a *App) MarkChannelAsUnreadFromPost(postID string, userID string) (*model.
} }
threadMembership, _ := a.Srv().Store.Thread().GetMembershipForUser(user.Id, threadId) threadMembership, _ := a.Srv().Store.Thread().GetMembershipForUser(user.Id, threadId)
// if this post was not followed before, create thread membership and update mention count
if threadMembership == nil { if threadMembership == nil {
threadMembership, _ = a.Srv().Store.Thread().MaintainMembership(user.Id, threadId, true, true, true, true, false) threadMembership, _ = a.Srv().Store.Thread().MaintainMembership(user.Id, threadId, true, true, true, true, false)
}
threadData, _ := a.Srv().Store.Thread().Get(threadId) threadData, _ := a.Srv().Store.Thread().Get(threadId)
if threadData != nil && threadMembership != nil && threadMembership.Following { if threadData != nil && threadMembership != nil && threadMembership.Following {
channel, nErr := a.Srv().Store.Channel().Get(post.ChannelId, true) channel, nErr := a.Srv().Store.Channel().Get(post.ChannelId, true)
@@ -2423,6 +2423,8 @@ func (a *App) MarkChannelAsUnreadFromPost(postID string, userID string) (*model.
} }
} }
}
channelUnread, nErr := a.Srv().Store.Channel().UpdateLastViewedAtPost(post, userID, unreadMentions, unreadMentionsRoot, *a.Config().ServiceSettings.ThreadAutoFollow) channelUnread, nErr := a.Srv().Store.Channel().UpdateLastViewedAtPost(post, userID, unreadMentions, unreadMentionsRoot, *a.Config().ServiceSettings.ThreadAutoFollow)
if nErr != nil { if nErr != nil {
return channelUnread, model.NewAppError("MarkChannelAsUnreadFromPost", "app.channel.update_last_viewed_at_post.app_error", nil, nErr.Error(), http.StatusInternalServerError) return channelUnread, model.NewAppError("MarkChannelAsUnreadFromPost", "app.channel.update_last_viewed_at_post.app_error", nil, nErr.Error(), http.StatusInternalServerError)

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

@@ -2289,7 +2289,7 @@ func (s SqlChannelStore) UpdateLastViewedAtPost(unreadPost *model.Post, userID s
} }
if updateThreads { if updateThreads {
s.Thread().UpdateUnreadsByChannel(userID, threadsToUpdate, unreadDate, true) s.Thread().UpdateUnreadsByChannel(userID, threadsToUpdate, unreadDate, false)
} }
return result, nil return result, nil
} }