fix: discord auto presence health signal (#33277) (thanks @thewilloftheshadow) (#33277)

This commit is contained in:
Shadow
2026-03-03 11:20:59 -06:00
committed by GitHub
parent 3d998828b9
commit e28ff1215c
13 changed files with 690 additions and 3 deletions

View File

@@ -37,7 +37,11 @@ export function resolveProfileUnusableUntil(
/**
* Check if a profile is currently in cooldown (due to rate limiting or errors).
*/
export function isProfileInCooldown(store: AuthProfileStore, profileId: string): boolean {
export function isProfileInCooldown(
store: AuthProfileStore,
profileId: string,
now?: number,
): boolean {
if (isAuthCooldownBypassedForProvider(store.profiles[profileId]?.provider)) {
return false;
}
@@ -46,7 +50,8 @@ export function isProfileInCooldown(store: AuthProfileStore, profileId: string):
return false;
}
const unusableUntil = resolveProfileUnusableUntil(stats);
return unusableUntil ? Date.now() < unusableUntil : false;
const ts = now ?? Date.now();
return unusableUntil ? ts < unusableUntil : false;
}
function isActiveUnusableWindow(until: number | undefined, now: number): boolean {