refactor(quota): migrate traffic quota from tunnel to user level

- Replace tunnel_quota table with user_quota table
- Add user-level daily/monthly quota tracking and enforcement
- Update user CRUD to include quota configuration
- Migrate backup/restore to use user quota fields
- Update frontend API and UI for user quota management
This commit is contained in:
sagitchu
2026-03-12 14:17:57 +08:00
parent 30d9552207
commit ad9b336fb9
19 changed files with 648 additions and 615 deletions
+10
View File
@@ -0,0 +1,10 @@
# User Traffic Quota (Fix PR #308 Semantics)
- [x] Confirm new quota semantics: daily/monthly quota applies per user (aggregated across all tunnels), not per tunnel; overage pauses only that user's active forwards and blocks create/resume.
- [x] Backend schema: replace `tunnel_quota` usage with new `user_quota` persistence model + view types.
- [x] Repository: implement user quota read/write/increment/reset + daily/monthly window rollover.
- [x] Handler: wire quota accumulation into flow uploads, enforce overage (pause forwards + mark quota-disabled), and add admin reset API.
- [x] Jobs: run daily quota window rollover + release logic in existing 00:05 maintenance job.
- [x] Backup/import: persist quota config + quota-disable metadata on user backup payloads (not rolling usage).
- [x] Tests: update contract + handler job tests to validate quota blocking + reset window rollover.
- [x] Frontend: move quota inputs/usage/reset UI from tunnel management to user management; update API/types accordingly.