fix: rework documents limits logic (#1836)

This commit is contained in:
David Nguyen
2025-06-12 13:42:31 +10:00
committed by GitHub
parent 8be7137b59
commit 614106a5e4

View File

@ -66,7 +66,7 @@ export const getServerLimits = async ({
};
}
// If plan expired.
// Early return for users with an expired subscription.
if (subscription && subscription.status !== SubscriptionStatus.ACTIVE) {
return {
quota: INACTIVE_PLAN_LIMITS,
@ -74,15 +74,15 @@ export const getServerLimits = async ({
};
}
if (subscription && organisation.organisationClaim.flags.unlimitedDocuments) {
// Allow unlimited documents for users with an unlimited documents claim.
// This also allows "free" claim users without subscriptions if they have this flag.
if (organisation.organisationClaim.flags.unlimitedDocuments) {
return {
quota: PAID_PLAN_LIMITS,
remaining: PAID_PLAN_LIMITS,
};
}
// If free tier or plan does not have unlimited documents.
if (!subscription || !organisation.organisationClaim.flags.unlimitedDocuments) {
const [documents, directTemplates] = await Promise.all([
prisma.document.count({
where: {
@ -116,10 +116,4 @@ export const getServerLimits = async ({
quota,
remaining,
};
}
return {
quota: PAID_PLAN_LIMITS,
remaining: PAID_PLAN_LIMITS,
};
};