Compare commits
2 Commits
f8f9d99e69
...
8bcb0094b2
| Author | SHA1 | Date | |
|---|---|---|---|
|
8bcb0094b2
|
|||
|
f39e4e6fb0
|
@@ -113,21 +113,19 @@ func (h *Handler) handleURLInput(ctx context.Context, chatID int64, text string,
|
||||
return
|
||||
}
|
||||
|
||||
// Reject if user has already exhausted quota (limit of 0 = unlimited).
|
||||
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.DailyLimitMB > 0 && q.DailyUsedMB >= q.DailyLimitMB) ||
|
||||
(q.WeeklyLimitMB > 0 && q.WeeklyUsedMB >= q.WeeklyLimitMB) ||
|
||||
(q.MonthlyLimitMB > 0 && 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