add controls for gms-errors to log or throw

This commit is contained in:
Claus-Peter Huebner 2024-03-14 02:07:16 +01:00
parent 6c75705cc3
commit 73382fce3d
3 changed files with 12 additions and 2 deletions

View File

@ -143,6 +143,7 @@ const federation = {
const gms = {
GMS_ACTIVE: process.env.GMS_ACTIVE === 'true' || false,
GMS_CREATE_USER_THROW_ERRORS: process.env.GMS_CREATE_USER_THROW_ERRORS === 'true' || false,
// koordinates of Illuminz-instance of GMS
GMS_URL: process.env.GMS_HOST ?? 'http://localhost:4044/',
}

View File

@ -376,7 +376,11 @@ export class UserResolver {
await sendUserToGms(dbUser, homeCom)
}
} catch (err) {
logger.error('Error publishing new created user to GMS:', err)
if (CONFIG.GMS_CREATE_USER_THROW_ERRORS) {
throw new LogError('Error publishing new created user to GMS:', err)
} else {
logger.error('Error publishing new created user to GMS:', err)
}
}
}
return new User(dbUser)

View File

@ -3,6 +3,7 @@ import { User as DbUser } from '@entity/User'
import { createGmsUser } from '@/apis/gms/GmsClient'
import { GmsUser } from '@/apis/gms/model/GmsUser'
import { CONFIG } from '@/config'
import { LogError } from '@/server/LogError'
import { backendLogger as logger } from '@/server/logger'
@ -22,6 +23,10 @@ export async function sendUserToGms(user: DbUser, homeCom: DbCommunity): Promise
logger.debug('mark user as gms published:', user)
}
} catch (err) {
logger.warn('publishing user fails with ', err)
if (CONFIG.GMS_CREATE_USER_THROW_ERRORS) {
throw new LogError('publishing user fails with ', err)
} else {
logger.warn('publishing user fails with ', err)
}
}
}