fix(handlers): bypass box creation limits for batched uploads
All checks were successful
Build and Publish Docker Image / deploy (push) Successful in 1m42s

Update `createOrAppendBox` to accept the upload policy and admin status, allowing policy enforcement to be handled during the box creation/append decision process. This ensures that appending files to an existing batch does not incorrectly trigger daily or active box creation limits, as no new box is being created.

Also, add unit tests to verify that batched uploads successfully bypass both daily and active box creation caps.
This commit is contained in:
2026-06-01 00:20:18 +03:00
parent 71d9b9db7e
commit 4eacb4cde2
8 changed files with 207 additions and 47 deletions

View File

@@ -519,6 +519,11 @@ func (s *BanService) RecordAbuse(ip, kind, detail string, threshold int, now tim
if err != nil || !triggered {
return AbuseResult{Event: event, Triggered: false, Enabled: true}, err
}
if matched, ok, err := s.Match(ip, now); err != nil {
return AbuseResult{}, err
} else if ok {
return AbuseResult{Event: event, Ban: matched.Ban, Triggered: true, Enabled: true}, nil
}
reason := fmt.Sprintf("%s threshold reached: %s", strings.ReplaceAll(kind, "_", " "), detail)
ban, err = s.createBan(ip, reason, BanSourceAuto, "", now.Add(time.Duration(settings.AutoBanDurationHours)*time.Hour), now)
if err != nil {