mirror of
https://github.com/documenso/documenso.git
synced 2026-06-22 04:12:06 +10:00
fix: track monthly usage for unlimited quotas (#2894)
This commit is contained in:
@@ -19,10 +19,6 @@ const COUNTER_COLUMN = {
|
||||
} as const satisfies Record<LimitCounter, string>;
|
||||
|
||||
export const checkMonthlyQuota = async (opts: CheckMonthlyQuotaOptions): Promise<void> => {
|
||||
if (opts.quota === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (opts.quota === 0) {
|
||||
throw new AppError(AppErrorCode.TOO_MANY_REQUESTS, {
|
||||
message:
|
||||
@@ -52,6 +48,11 @@ export const checkMonthlyQuota = async (opts: CheckMonthlyQuotaOptions): Promise
|
||||
},
|
||||
});
|
||||
|
||||
// For unlimited quotas, we still allow the request to send so we can collect the monthly stat.
|
||||
if (opts.quota === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
const newCount = latestMonthlyStat[column];
|
||||
const previousCount = newCount - opts.count;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user