Tenantid optional

This commit is contained in:
Adria Navarro 2023-09-19 12:08:59 +02:00
parent 6f1d027126
commit 7b4585ce68
1 changed files with 2 additions and 1 deletions

View File

@ -110,7 +110,7 @@ export async function getUser(
* @param {*} tenantId the tenant of the users to get * @param {*} tenantId the tenant of the users to get
* @returns * @returns
*/ */
export async function getUsers(userIds: string[], tenantId: string) { export async function getUsers(userIds: string[], tenantId?: string) {
const client = await redis.getUserClient() const client = await redis.getUserClient()
// try cache // try cache
let usersFromCache = await client.bulkGet(userIds) let usersFromCache = await client.bulkGet(userIds)
@ -118,6 +118,7 @@ export async function getUsers(userIds: string[], tenantId: string) {
const users = Object.values(usersFromCache) const users = Object.values(usersFromCache)
if (missingUsersFromCache.length) { if (missingUsersFromCache.length) {
tenantId ??= context.getTenantId()
const usersFromDb = await populateUsersFromDB( const usersFromDb = await populateUsersFromDB(
missingUsersFromCache, missingUsersFromCache,
tenantId tenantId