Excludes remote channels from channel search (#28708)
* Excludes remote channels from channel search This is done through a new body parameter in the SearchAllChannels endpoint that allows to search for local only channels, which are either channels that are shared but marked as homed locally, or channels that are not shared at all. * fix lint * Fix tests --------- Co-authored-by: Caleb Roseland <caleb@calebroseland.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
f06742c7e2
Коммит
b4d8b6239c
@@ -1299,6 +1299,7 @@ func searchAllChannels(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
ExcludeGroupConstrained: props.ExcludeGroupConstrained,
|
||||
ExcludePolicyConstrained: props.ExcludePolicyConstrained,
|
||||
IncludeSearchById: props.IncludeSearchById,
|
||||
ExcludeRemote: props.ExcludeRemote,
|
||||
Public: props.Public,
|
||||
Private: props.Private,
|
||||
IncludeDeleted: includeDeleted,
|
||||
|
||||
@@ -1696,7 +1696,7 @@ func TestSearchArchivedChannels(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSearchAllChannels(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
th := setupForSharedChannels(t).InitBasic()
|
||||
th.LoginSystemManager()
|
||||
defer th.TearDown()
|
||||
client := th.Client
|
||||
@@ -1737,6 +1737,29 @@ func TestSearchAllChannels(t *testing.T) {
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
// share the open and private channels, one homed locally and the
|
||||
// other remotely
|
||||
sco := &model.SharedChannel{
|
||||
ChannelId: openChannel.Id,
|
||||
TeamId: openChannel.TeamId,
|
||||
Home: true,
|
||||
ShareName: "testsharelocal",
|
||||
CreatorId: th.BasicChannel.CreatorId,
|
||||
}
|
||||
_, scoErr := th.App.ShareChannel(th.Context, sco)
|
||||
require.NoError(t, scoErr)
|
||||
|
||||
scp := &model.SharedChannel{
|
||||
ChannelId: privateChannel.Id,
|
||||
TeamId: privateChannel.TeamId,
|
||||
Home: false,
|
||||
RemoteId: model.NewId(),
|
||||
ShareName: "testshareremote",
|
||||
CreatorId: th.BasicChannel.CreatorId,
|
||||
}
|
||||
_, scpErr := th.App.ShareChannel(th.Context, scp)
|
||||
require.NoError(t, scpErr)
|
||||
|
||||
testCases := []struct {
|
||||
Description string
|
||||
Search *model.ChannelSearch
|
||||
@@ -1847,6 +1870,11 @@ func TestSearchAllChannels(t *testing.T) {
|
||||
&model.ChannelSearch{Term: "SearchAllChannels", ExcludeGroupConstrained: true},
|
||||
[]string{openChannel.Id, privateChannel.Id},
|
||||
},
|
||||
{
|
||||
"Search for local only channels",
|
||||
&model.ChannelSearch{Term: "SearchAllChannels", ExcludeRemote: true},
|
||||
[]string{openChannel.Id, groupConstrainedChannel.Id},
|
||||
},
|
||||
}
|
||||
for _, testCase := range testCases {
|
||||
t.Run(testCase.Description, func(t *testing.T) {
|
||||
|
||||
Ссылка в новой задаче
Block a user