[MM-37118] Don't mark channel as read for reply posts with CRT on (#17965)
Summary With CRT on, posting a reply to a thread should NOT mark the channel containing the the thread as read Ticket Link https://mattermost.atlassian.net/browse/MM-37118
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
c61c649c02
Коммит
0f07a934ff
@@ -964,6 +964,77 @@ func TestCreatePostAsUser(t *testing.T) {
|
||||
|
||||
testlib.AssertNoLog(t, th.LogBuffer, mlog.LevelWarn, "Failed to get membership")
|
||||
})
|
||||
|
||||
t.Run("marks channel as viewed for reply post when CRT is off", func(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.ServiceSettings.CollapsedThreads = model.CollapsedThreadsDefaultOff
|
||||
})
|
||||
|
||||
post := &model.Post{
|
||||
ChannelId: th.BasicChannel.Id,
|
||||
Message: "test",
|
||||
UserId: th.BasicUser2.Id,
|
||||
}
|
||||
rootPost, appErr := th.App.CreatePostAsUser(th.Context, post, "", true)
|
||||
require.Nil(t, appErr)
|
||||
|
||||
channelMemberBefore, nErr := th.App.Srv().Store.Channel().GetMember(context.Background(), th.BasicChannel.Id, th.BasicUser.Id)
|
||||
require.NoError(t, nErr)
|
||||
|
||||
time.Sleep(1 * time.Millisecond)
|
||||
replyPost := &model.Post{
|
||||
ChannelId: th.BasicChannel.Id,
|
||||
Message: "test reply",
|
||||
UserId: th.BasicUser.Id,
|
||||
RootId: rootPost.Id,
|
||||
}
|
||||
_, appErr = th.App.CreatePostAsUser(th.Context, replyPost, "", true)
|
||||
require.Nil(t, appErr)
|
||||
|
||||
channelMemberAfter, nErr := th.App.Srv().Store.Channel().GetMember(context.Background(), th.BasicChannel.Id, th.BasicUser.Id)
|
||||
require.NoError(t, nErr)
|
||||
|
||||
require.NotEqual(t, channelMemberAfter.LastViewedAt, channelMemberBefore.LastViewedAt)
|
||||
})
|
||||
|
||||
t.Run("does not mark channel as viewed for reply post when CRT is on", func(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.ServiceSettings.ThreadAutoFollow = true
|
||||
*cfg.ServiceSettings.CollapsedThreads = model.CollapsedThreadsDefaultOn
|
||||
})
|
||||
|
||||
post := &model.Post{
|
||||
ChannelId: th.BasicChannel.Id,
|
||||
Message: "test",
|
||||
UserId: th.BasicUser2.Id,
|
||||
}
|
||||
rootPost, appErr := th.App.CreatePostAsUser(th.Context, post, "", true)
|
||||
require.Nil(t, appErr)
|
||||
|
||||
channelMemberBefore, nErr := th.App.Srv().Store.Channel().GetMember(context.Background(), th.BasicChannel.Id, th.BasicUser.Id)
|
||||
require.NoError(t, nErr)
|
||||
|
||||
time.Sleep(1 * time.Millisecond)
|
||||
replyPost := &model.Post{
|
||||
ChannelId: th.BasicChannel.Id,
|
||||
Message: "test reply",
|
||||
UserId: th.BasicUser.Id,
|
||||
RootId: rootPost.Id,
|
||||
}
|
||||
_, appErr = th.App.CreatePostAsUser(th.Context, replyPost, "", true)
|
||||
require.Nil(t, appErr)
|
||||
|
||||
channelMemberAfter, nErr := th.App.Srv().Store.Channel().GetMember(context.Background(), th.BasicChannel.Id, th.BasicUser.Id)
|
||||
require.NoError(t, nErr)
|
||||
|
||||
require.Equal(t, channelMemberAfter.LastViewedAt, channelMemberBefore.LastViewedAt)
|
||||
})
|
||||
}
|
||||
|
||||
func TestPatchPostInArchivedChannel(t *testing.T) {
|
||||
|
||||
Ссылка в новой задаче
Block a user