( uid: string, userInfoOverride?: Pick<DBUser, "premium">, )
| 1191 | } |
| 1192 | |
| 1193 | export 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 | |
| 1212 | export async function logIpAddress( |
| 1213 | uid: string, |
nothing calls this directly
no test coverage detected