MM-34758 Collapsed Reply Threads without mobile support (#17424)

Summary
added support for legacy clients accessing server
added collapsed_threads_supported param to viewChannel API and setPostUnread API

Ticket Link
https://mattermost.atlassian.net/browse/MM-34758

Related Webapp PR
mattermost/mattermost-webapp#7933
Этот коммит содержится в:
Eli Yukelzon
2021-05-26 18:10:25 +03:00
коммит произвёл GitHub
родитель ebed0c67f7
Коммит 46649292f8
21 изменённых файлов: 417 добавлений и 65 удалений

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

@@ -7,6 +7,7 @@ import (
"context"
"fmt"
"net/http"
"os"
"sort"
"strings"
"sync"
@@ -4178,6 +4179,7 @@ func TestMoveChannel(t *testing.T) {
func TestRootMentionsCount(t *testing.T) {
th := Setup(t).InitBasic()
defer th.TearDown()
Client := th.Client
user := th.BasicUser
channel := th.BasicChannel
@@ -4214,3 +4216,44 @@ func TestRootMentionsCount(t *testing.T) {
require.Equal(t, int64(1), counts.MentionCountRoot)
require.Equal(t, int64(2), counts.MentionCount)
}
func TestViewChannelWithoutCollapsedThreads(t *testing.T) {
th := Setup(t).InitBasic()
defer th.TearDown()
os.Setenv("MM_FEATUREFLAGS_COLLAPSEDTHREADS", "true")
defer os.Unsetenv("MM_FEATUREFLAGS_COLLAPSEDTHREADS")
th.App.UpdateConfig(func(cfg *model.Config) {
*cfg.ServiceSettings.ThreadAutoFollow = true
*cfg.ServiceSettings.CollapsedThreads = model.COLLAPSED_THREADS_DEFAULT_ON
})
Client := th.Client
user := th.BasicUser
team := th.BasicTeam
channel := th.BasicChannel
// mention the user in a root post
post1, resp := th.SystemAdminClient.CreatePost(&model.Post{ChannelId: channel.Id, Message: "hey @" + user.Username})
CheckNoError(t, resp)
// mention the user in a reply post
post2 := &model.Post{ChannelId: channel.Id, Message: "reply at @" + user.Username, RootId: post1.Id}
_, resp = th.SystemAdminClient.CreatePost(post2)
CheckNoError(t, resp)
threads, resp := Client.GetUserThreads(user.Id, team.Id, model.GetUserThreadsOpts{})
CheckNoError(t, resp)
require.EqualValues(t, int64(1), threads.TotalUnreadMentions)
// simulate opening the channel from an old client
_, resp = Client.ViewChannel(user.Id, &model.ChannelView{
ChannelId: channel.Id,
PrevChannelId: "",
CollapsedThreadsSupported: false,
})
CheckNoError(t, resp)
threads, resp = Client.GetUserThreads(user.Id, team.Id, model.GetUserThreadsOpts{})
CheckNoError(t, resp)
require.Zero(t, threads.TotalUnreadMentions)
}