Improves get roles by names requests to batch them following the new endpoint limit (#7650)
This commit is contained in:
parent
d6566b591a
commit
4095212d86
2 changed files with 9 additions and 1 deletions
|
|
@ -1,6 +1,7 @@
|
|||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import {General} from '@constants';
|
||||
import DatabaseManager from '@database/manager';
|
||||
import NetworkManager from '@managers/network_manager';
|
||||
import {queryRoles} from '@queries/servers/role';
|
||||
|
|
@ -42,7 +43,13 @@ export const fetchRolesIfNeeded = async (serverUrl: string, updatedRoles: string
|
|||
return {roles: []};
|
||||
}
|
||||
|
||||
const roles = await client.getRolesByNames(newRoles);
|
||||
const getRolesRequests = [];
|
||||
for (let i = 0; i < newRoles.length; i += General.MAX_GET_ROLES_BY_NAMES) {
|
||||
const chunk = newRoles.slice(i, i + General.MAX_GET_ROLES_BY_NAMES);
|
||||
getRolesRequests.push(client.getRolesByNames(chunk));
|
||||
}
|
||||
|
||||
const roles = (await Promise.all(getRolesRequests)).flat();
|
||||
if (!fetchOnly) {
|
||||
await operator.handleRole({
|
||||
roles,
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ export default {
|
|||
MAX_USERS_IN_GM: 7,
|
||||
MIN_USERS_IN_GM: 3,
|
||||
MAX_GROUP_CHANNELS_FOR_PROFILES: 50,
|
||||
MAX_GET_ROLES_BY_NAMES: 100,
|
||||
DEFAULT_AUTOLINKED_URL_SCHEMES: ['http', 'https', 'ftp', 'mailto', 'tel', 'mattermost'],
|
||||
PROFILE_CHUNK_SIZE: 100,
|
||||
SEARCH_TIMEOUT_MILLISECONDS: 500,
|
||||
|
|
|
|||
Loading…
Reference in a new issue