mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 09:28:06 +00:00
Add org caching + fix a line
This commit is contained in:
@@ -1434,14 +1434,21 @@ export const orgServiceFactory = ({
|
|||||||
const invitedUsers = await orgMembershipDAL.findRecentInvitedMemberships();
|
const invitedUsers = await orgMembershipDAL.findRecentInvitedMemberships();
|
||||||
const appCfg = getConfig();
|
const appCfg = getConfig();
|
||||||
|
|
||||||
|
const orgCache: Record<string, { name: string; id: string } | undefined> = {};
|
||||||
|
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
invitedUsers.map(async (invitedUser) => {
|
invitedUsers.map(async (invitedUser) => {
|
||||||
const org = await orgDAL.findById(invitedUser.orgId);
|
let org = orgCache[invitedUser.orgId];
|
||||||
if (!org) return;
|
if (!org) {
|
||||||
|
org = await orgDAL.findById(invitedUser.orgId);
|
||||||
|
orgCache[invitedUser.orgId] = org;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!org || !invitedUser.userId) return;
|
||||||
|
|
||||||
const token = await tokenService.createTokenForUser({
|
const token = await tokenService.createTokenForUser({
|
||||||
type: TokenType.TOKEN_EMAIL_ORG_INVITATION,
|
type: TokenType.TOKEN_EMAIL_ORG_INVITATION,
|
||||||
userId: invitedUser.id,
|
userId: invitedUser.userId,
|
||||||
orgId: org.id
|
orgId: org.id
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user