's'
This commit is contained in:
@@ -35,6 +35,8 @@ type RecoveryResult = {
|
||||
source?: string;
|
||||
};
|
||||
|
||||
const inflightEmailChecks = new Map<string, Promise<PayjsVipEmailResult | null>>();
|
||||
|
||||
const PAYJS_CHECK_BY_EMAIL_TIMEOUT =
|
||||
Number(process.env.PAYJSAPI_CHECK_BY_EMAIL_TIMEOUT) || 20000;
|
||||
const PAYJS_CHECK_BY_EMAIL_RETRIES =
|
||||
@@ -62,6 +64,13 @@ async function checkVipByEmailFromPayjsapi(
|
||||
password: string,
|
||||
userId?: string
|
||||
): Promise<PayjsVipEmailResult | null> {
|
||||
const inflightKey = `${email}::${userId || ""}`;
|
||||
const existed = inflightEmailChecks.get(inflightKey);
|
||||
if (existed) {
|
||||
return existed;
|
||||
}
|
||||
|
||||
const task = (async () => {
|
||||
const payConfig = getPaymentConfig();
|
||||
const primaryUrl = resolvePayApiUrl(request);
|
||||
const localUrl = getLocalPayApiUrl();
|
||||
@@ -125,6 +134,14 @@ async function checkVipByEmailFromPayjsapi(
|
||||
}
|
||||
}
|
||||
return null;
|
||||
})();
|
||||
|
||||
inflightEmailChecks.set(inflightKey, task);
|
||||
try {
|
||||
return await task;
|
||||
} finally {
|
||||
inflightEmailChecks.delete(inflightKey);
|
||||
}
|
||||
}
|
||||
|
||||
async function loginPocketBaseUser(
|
||||
|
||||
Reference in New Issue
Block a user