fix: quota pre-check used max format size, blocked before format selection
Changed pre-check to only reject when used >= limit (already exhausted), not when the max format size alone would exceed the limit. The actual quota is applied at 50% progress using the selected format's size.
This commit is contained in:
@@ -113,21 +113,17 @@ func (h *Handler) handleURLInput(ctx context.Context, chatID int64, text string,
|
||||
return
|
||||
}
|
||||
|
||||
// Reject if user has already exhausted quota (used >= limit) with a minimum threshold.
|
||||
q, err := h.Repo.GetOrCreateQuotas(userID)
|
||||
if err == nil {
|
||||
q = h.resetQuotasIfNeeded(q)
|
||||
estimatedMB := info.EstimatedSize / (1024 * 1024)
|
||||
if estimatedMB > 0 {
|
||||
if q.DailyUsedMB+estimatedMB > q.DailyLimitMB ||
|
||||
q.WeeklyUsedMB+estimatedMB > q.WeeklyLimitMB ||
|
||||
q.MonthlyUsedMB+estimatedMB > q.MonthlyLimitMB {
|
||||
if q.DailyUsedMB >= q.DailyLimitMB || q.WeeklyUsedMB >= q.WeeklyLimitMB || q.MonthlyUsedMB >= q.MonthlyLimitMB {
|
||||
h.sendText(ctx, chatID, fmt.Sprintf(
|
||||
"Quota exceeded. Daily: %d/%d MB, Weekly: %d/%d MB, Monthly: %d/%d MB.",
|
||||
q.DailyUsedMB, q.DailyLimitMB, q.WeeklyUsedMB, q.WeeklyLimitMB, q.MonthlyUsedMB, q.MonthlyLimitMB))
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ss := &stepState{
|
||||
URL: url,
|
||||
|
||||
Reference in New Issue
Block a user