Adding the option to disable user sync, always importing large apps which are problematic.

This commit is contained in:
mike12345567 2024-08-30 13:44:23 +01:00
parent a9b1a22403
commit 6730105491
2 changed files with 9 additions and 2 deletions

View File

@ -112,6 +112,7 @@ const environment = {
parseIntSafe(process.env.JS_RUNNER_MEMORY_LIMIT) ||
DEFAULTS.JS_RUNNER_MEMORY_LIMIT,
LOG_JS_ERRORS: process.env.LOG_JS_ERRORS,
DISABLE_USER_SYNC: process.env.DISABLE_USER_SYNC,
// old
CLIENT_ID: process.env.CLIENT_ID,
_set(key: string, value: any) {

View File

@ -8,6 +8,10 @@ import { generateUserMetadataID, InternalTables } from "../../../db/utils"
type DeletedUser = { _id: string; deleted: boolean }
function userSyncEnabled() {
return !env.DISABLE_USER_SYNC
}
async function syncUsersToApp(
appId: string,
users: (User | DeletedUser)[],
@ -56,7 +60,7 @@ async function syncUsersToApp(
// the user doesn't exist, or doesn't have a role anymore
// get rid of their metadata
if (deletedUser || !roleId) {
if (userSyncEnabled() && (deletedUser || !roleId)) {
await db.remove(metadata)
continue
}
@ -149,7 +153,9 @@ export async function syncApp(
}
// sync the users - kept for safe keeping
await sdk.users.syncGlobalUsers()
if (userSyncEnabled()) {
await sdk.users.syncGlobalUsers()
}
if (error) {
throw error