MCPcopy Create free account
hub / github.com/monkeytypegame/monkeytype / checkIfUserIsPremium

Function checkIfUserIsPremium

backend/src/dal/user.ts:1193–1210  ·  view source on GitHub ↗
(
  uid: string,
  userInfoOverride?: Pick<DBUser, "premium">,
)

Source from the content-addressed store, hash-verified

1191}
1192
1193export async function checkIfUserIsPremium(
1194 uid: string,
1195 userInfoOverride?: Pick<DBUser, "premium">,
1196): Promise<boolean> {
1197 const premiumFeaturesEnabled = (await getCachedConfiguration(true)).users
1198 .premium.enabled;
1199 if (!premiumFeaturesEnabled) {
1200 return false;
1201 }
1202 const user =
1203 userInfoOverride ??
1204 (await getPartialUser(uid, "checkIfUserIsPremium", ["premium"]));
1205 const expirationDate = user.premium?.expirationTimestamp;
1206
1207 if (expirationDate === undefined) return false;
1208 if (expirationDate === -1) return true; //lifetime
1209 return expirationDate > Date.now();
1210}
1211
1212export async function logIpAddress(
1213 uid: string,

Callers

nothing calls this directly

Calls 2

getCachedConfigurationFunction · 0.90
getPartialUserFunction · 0.85

Tested by

no test coverage detected