Skip to content

Open source CapCut alternative.

TypeScript

refactor(site): expose the per-tier Cut limits rule as a pure function [rebuild]

David Lebdb339b6e5a7
diff --git a/site/src/cut/server/cloud/limits.ts b/site/src/cut/server/cloud/limits.ts
index 3a42f210..12841e7d 100644
--- a/site/src/cut/server/cloud/limits.ts
+++ b/site/src/cut/server/cloud/limits.ts
@@ -24,9 +24,15 @@ const FREE: CutLimits = { storageBytes: FREE_STORAGE_BYTES, renderJobsPerDay: 10
const PRO: CutLimits = { storageBytes: 100 * 1024 ** 3, renderJobsPerDay: 200 };
const UNLIMITED: CutLimits = { storageBytes: null, renderJobsPerDay: null };
+/** The limits an account's tier earns. Super users are unlimited. */
+export function cutLimitsForTier(tier: { superUser: boolean; pro: boolean }): CutLimits {
+ if (tier.superUser) return UNLIMITED;
+ return tier.pro ? PRO : FREE;
+}
+
export async function cutLimitsFor(userId: string): Promise<CutLimits> {
if (await isDonkeySuperUser(userId)) return UNLIMITED;
- return (await getActiveProSubscription(userId)) ? PRO : FREE;
+ return cutLimitsForTier({ superUser: false, pro: !!(await getActiveProSubscription(userId)) });
}
/** 429 when another counted render job would break the daily cap, else null. */