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
@@ -79,7 +79,7 @@ function SharedChannelsAddModal({
|
||||
return [];
|
||||
}
|
||||
|
||||
const {data} = await dispatch(searchAllChannels(query, {page: 0, per_page: 20, signal}));
|
||||
const {data} = await dispatch(searchAllChannels(query, {page: 0, per_page: 20, exclude_remote: true, signal}));
|
||||
if (data) {
|
||||
return data.channels.filter(({id}) => {
|
||||
const remote = remotesByChannelId?.[id];
|
||||
|
||||
@@ -1132,7 +1132,7 @@ describe('Actions.Channels', () => {
|
||||
);
|
||||
|
||||
nock(Client4.getBaseRoute()).
|
||||
post('/channels/search?include_deleted=false').
|
||||
post('/channels/search?include_deleted=false&exclude_remote=false').
|
||||
reply(200, [TestHelper.basicChannel, userChannel]);
|
||||
|
||||
await store.dispatch(Actions.searchAllChannels('test', {}));
|
||||
@@ -1143,7 +1143,7 @@ describe('Actions.Channels', () => {
|
||||
}
|
||||
|
||||
nock(Client4.getBaseRoute()).
|
||||
post('/channels/search?include_deleted=false').
|
||||
post('/channels/search?include_deleted=false&exclude_remote=false').
|
||||
reply(200, {channels: [TestHelper.basicChannel, userChannel], total_count: 2});
|
||||
|
||||
let response = await store.dispatch(Actions.searchAllChannels('test', {exclude_default_channels: false, page: 0, per_page: 100}));
|
||||
@@ -1156,7 +1156,7 @@ describe('Actions.Channels', () => {
|
||||
expect(response.data.channels.length === 2).toBeTruthy();
|
||||
|
||||
nock(Client4.getBaseRoute()).
|
||||
post('/channels/search?include_deleted=true').
|
||||
post('/channels/search?include_deleted=true&exclude_remote=false').
|
||||
reply(200, {channels: [TestHelper.basicChannel, userChannel], total_count: 2});
|
||||
|
||||
response = await store.dispatch(Actions.searchAllChannels('test', {exclude_default_channels: false, page: 0, per_page: 100, include_deleted: true}));
|
||||
|
||||
@@ -1961,7 +1961,8 @@ export default class Client4 {
|
||||
};
|
||||
const includeDeleted = Boolean(opts.include_deleted);
|
||||
const nonAdminSearch = Boolean(opts.nonAdminSearch);
|
||||
let queryParams: {include_deleted?: boolean; system_console?: boolean} = {include_deleted: includeDeleted};
|
||||
const excludeRemote = Boolean(opts.exclude_remote);
|
||||
let queryParams: {include_deleted?: boolean; system_console?: boolean; exclude_remote?: boolean} = {include_deleted: includeDeleted, exclude_remote: excludeRemote};
|
||||
if (nonAdminSearch) {
|
||||
queryParams = {system_console: false};
|
||||
delete body.nonAdminSearch;
|
||||
|
||||
@@ -211,6 +211,7 @@ export type ChannelSearchOpts = {
|
||||
private?: boolean;
|
||||
include_deleted?: boolean;
|
||||
include_search_by_id?: boolean;
|
||||
exclude_remote?: boolean;
|
||||
deleted?: boolean;
|
||||
page?: number;
|
||||
per_page?: number;
|
||||
|
||||
Ссылка в новой задаче
Block a user