fix(client): refuse a bulk quota reduction that would fall to or below zero

BulkAdjust clamped a client's new traffic limit with max(total+addBytes, 0).
Because 0 is the unlimited sentinel, reducing a client's quota by more than
it had left silently granted that client unlimited traffic. The sibling
expiry branch already refuses an over-reduction; mirror it for quota so the
adjustment is skipped with a clear reason instead of crossing the sentinel.
This commit is contained in:
MHSanaei
2026-07-14 23:36:30 +02:00
parent 448e8c97c2
commit 7b266a9001
2 changed files with 34 additions and 3 deletions
+9 -3
View File
@@ -359,9 +359,15 @@ func (s *ClientService) BulkAdjust(inboundSvc *InboundService, emails []string,
skippedReasons[email] = "unlimited traffic"
}
} else {
next := max(rec.TotalGB+addBytes, 0)
entry.applyTotal = true
entry.newTotal = next
next := rec.TotalGB + addBytes
if next <= 0 {
if _, exists := skippedReasons[email]; !exists {
skippedReasons[email] = "reduction exceeds remaining quota"
}
} else {
entry.applyTotal = true
entry.newTotal = next
}
}
}
if entry.applyExpiry || entry.applyTotal || adjustFlow {