MM-34895: LastViewed should be updated correctly for new thread membership (#17673)
Summary Update LastViewed correctly for new thread membership Ticket Link https://mattermost.atlassian.net/browse/MM-34895
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
6f5e14dd5e
Коммит
a95f90cec7
@@ -5766,8 +5766,8 @@ func TestMaintainUnreadRepliesInThread(t *testing.T) {
|
|||||||
// replying to the thread clears reply count, so it should be 0
|
// replying to the thread clears reply count, so it should be 0
|
||||||
checkThreadListReplies(t, th, th.Client, th.BasicUser.Id, 0, 1, nil)
|
checkThreadListReplies(t, th, th.Client, th.BasicUser.Id, 0, 1, nil)
|
||||||
|
|
||||||
// the other user should have 2 replies
|
// the other user should have 1 reply - the reply from the regular user
|
||||||
checkThreadListReplies(t, th, th.SystemAdminClient, th.SystemAdminUser.Id, 2, 1, nil)
|
checkThreadListReplies(t, th, th.SystemAdminClient, th.SystemAdminUser.Id, 1, 1, nil)
|
||||||
|
|
||||||
// mark all as read for user
|
// mark all as read for user
|
||||||
resp := th.Client.UpdateThreadsReadForUser(th.BasicUser.Id, th.BasicTeam.Id)
|
resp := th.Client.UpdateThreadsReadForUser(th.BasicUser.Id, th.BasicTeam.Id)
|
||||||
|
|||||||
@@ -521,11 +521,15 @@ func (s *SqlThreadStore) MaintainMembership(userId, postId string, following, in
|
|||||||
if incrementMentions {
|
if incrementMentions {
|
||||||
mentions = 1
|
mentions = 1
|
||||||
}
|
}
|
||||||
|
var lastViewed int64
|
||||||
|
if updateViewedTimestamp {
|
||||||
|
lastViewed = now
|
||||||
|
}
|
||||||
membership, err = s.SaveMembership(&model.ThreadMembership{
|
membership, err = s.SaveMembership(&model.ThreadMembership{
|
||||||
PostId: postId,
|
PostId: postId,
|
||||||
UserId: userId,
|
UserId: userId,
|
||||||
Following: following,
|
Following: following,
|
||||||
LastViewed: 0,
|
LastViewed: lastViewed,
|
||||||
LastUpdated: now,
|
LastUpdated: now,
|
||||||
UnreadMentions: int64(mentions),
|
UnreadMentions: int64(mentions),
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -297,11 +297,9 @@ func testThreadStorePopulation(t *testing.T, ss store.Store) {
|
|||||||
t.Run("Thread membership 'viewed' timestamp is updated properly", func(t *testing.T) {
|
t.Run("Thread membership 'viewed' timestamp is updated properly", func(t *testing.T) {
|
||||||
newPosts := makeSomePosts()
|
newPosts := makeSomePosts()
|
||||||
|
|
||||||
_, e := ss.Thread().MaintainMembership(newPosts[0].UserId, newPosts[0].Id, true, false, true, false, false)
|
tm, e := ss.Thread().MaintainMembership(newPosts[0].UserId, newPosts[0].Id, true, false, true, false, false)
|
||||||
require.NoError(t, e)
|
require.NoError(t, e)
|
||||||
m, err1 := ss.Thread().GetMembershipForUser(newPosts[0].UserId, newPosts[0].Id)
|
require.Equal(t, int64(0), tm.LastViewed)
|
||||||
require.NoError(t, err1)
|
|
||||||
require.Equal(t, int64(0), m.LastViewed)
|
|
||||||
|
|
||||||
_, e = ss.Thread().MaintainMembership(newPosts[0].UserId, newPosts[0].Id, true, false, true, true, false)
|
_, e = ss.Thread().MaintainMembership(newPosts[0].UserId, newPosts[0].Id, true, false, true, true, false)
|
||||||
require.NoError(t, e)
|
require.NoError(t, e)
|
||||||
@@ -310,6 +308,13 @@ func testThreadStorePopulation(t *testing.T, ss store.Store) {
|
|||||||
require.Greater(t, m2.LastViewed, int64(0))
|
require.Greater(t, m2.LastViewed, int64(0))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
t.Run("Thread membership 'viewed' timestamp is updated properly for new membership", func(t *testing.T) {
|
||||||
|
newPosts := makeSomePosts()
|
||||||
|
tm, e := ss.Thread().MaintainMembership(newPosts[0].UserId, newPosts[0].Id, true, false, false, true, false)
|
||||||
|
require.NoError(t, e)
|
||||||
|
require.NotEqual(t, int64(0), tm.LastViewed)
|
||||||
|
})
|
||||||
|
|
||||||
t.Run("Thread last updated is changed when channel is updated after UpdateLastViewedAtPost for mark unread", func(t *testing.T) {
|
t.Run("Thread last updated is changed when channel is updated after UpdateLastViewedAtPost for mark unread", func(t *testing.T) {
|
||||||
newPosts := makeSomePosts()
|
newPosts := makeSomePosts()
|
||||||
_, e := ss.Thread().MaintainMembership(newPosts[0].UserId, newPosts[0].Id, true, false, true, false, false)
|
_, e := ss.Thread().MaintainMembership(newPosts[0].UserId, newPosts[0].Id, true, false, true, false, false)
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user