Repository navigation
fix(users): preserve on-hold next-plan activation - #948
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
Walkthrough
ChangesUser reset behavior
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Suggested reviewers: Merge Risk | ⚪ Minimal · up to
|
| Check name | Status | Explanation |
|---|---|---|
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check | ✅ Passed | The title clearly and concisely describes the main change: preserving on-hold activation for users assigned a next plan. |
| Docstring Coverage | ✅ Passed | Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. |
| Linked Issues check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
✨ Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
A rabbit checks the clock at dawn
One timestamp guides the plan along
On-hold stays when templates say
Timeout fields are set that way
Then hops off, content with the change
Comment @coderabbitai help to get the list of available commands.
|
@coderabbitai review |
✅ Action performedReview finished.
|
d6d1ca4 to
ea9a948
Compare
An on-hold template next plan keeps the user on hold with the template's timeout as a deadline, and an immediate template plan clears an on-hold user's hold fields. Both fail before this fix. The user template helper gains an optional on_hold_timeout.
…ain bba95f274 Checked with git ls-remote on 2026-10-11 02:55 UTC. Panel dev moved from d94e157 to 83fe90e with 22 commits; main is still v5.4.1. - PasarGuard#879 (2d0ca81, loopback Xray client inbounds) is ported by design: the fork took the open pull request on 2026-09-25 as 2e7fc45 with migration bfd88026565b, the same listener rewrite. - PasarGuard#934 (a5b28f3) moves from the port queue to a dated waiver until 2026-11-09: the fork refuses to delete a core that nodes still use (W3-013, fix/node-health) instead of restarting those nodes. - PasarGuard#993 (Hysteria2 FinalMask without a udp mask) is queued until 2026-10-18: the fork has the same FinalMask | dict field and the same non-null-safe udpHop reads, so a udpHop-only host can fail the whole subscription. - PasarGuard#984, PasarGuard#985, PasarGuard#986, PasarGuard#989, PasarGuard#944, PasarGuard#864, PasarGuard#948, PasarGuard#951, PasarGuard#778, PasarGuard#774, PasarGuard#787, PasarGuard#994, PasarGuard#865, PasarGuard#875, PasarGuard#718, PasarGuard#967, PasarGuard#772, PasarGuard#662, PasarGuard#995 and PasarGuard#913 are queued as security: no until 2026-10-25, each with its reason; PasarGuard#913's node-removal half is already in the fork through sync_remove_users. - The branch commits that upstream squash-merged (the three dashboard branches, telegram/tests, fix/core-editor-api-section-followup, fix/hwid-count-test-cleanup, fix/hysteria-finalmask-quic-only) follow their squash, by patch-id or by an equal tree. Scripts main moved to bba95f274 (PasarGuard#35, PasarGuard#36, PasarGuard#37 after PasarGuard#34). The three squashes are queued security: no until 2026-10-25, and their pre-squash branch commits are waived as superseded (equal trees). Against live upstream the panel gate now fails only on the 17 port-queue commits classified security: yes, and the forks gate only on node f72ac0ef (security: yes). No upstream commit is undecided.
* fix(users): preserve on-hold next-plan activation * test(users): cover on-hold next-plan activation An on-hold template next plan keeps the user on hold with the template's timeout as a deadline, and an immediate template plan clears an on-hold user's hold fields. Both fail before this fix. The user template helper gains an optional on_hold_timeout. --------- Co-authored-by: T3ST3ST3R0N <[email protected]> Fork resolution: reset_user_by_next keeps the fork's proxy-secrets named lock, the FOR UPDATE refresh of the user and of the next plan, and NextPlanUnavailable, all before any field is written. The fork's 'only force active when not on_hold' tail is dropped in favour of upstream's reset-to-active at the start, which keeps the fork's test_reset_by_next_preserves_on_hold_template_status green. Upstream's test hunks are already in the RED commit before this pick. (cherry picked from commit aa59258)
Activating a next-plan template configured to start on first connection currently starts its expiration immediately. The template uses
UserStatusCreate, but activation compares it by identity withUserStatus; activation also unconditionally overwrites the result withactive. A customer who connects a week after a 30-day renewal therefore loses a week of validity.Compare against the template enum and preserve
on_holdthrough activation. Convert the template's timeout duration into a deadline relative to renewal, clear the previous plan's connection timestamp, and record the renewal time so only subsequent activity can start the plan. Immediate-start plans clear stale hold settings and retain their normal expiration behavior. Both manual activation and automatic expiration/traffic-limit renewal use this shared path.Validation: 14 temporary SQLite regression cases plus all 14 existing review-user unit tests passed (28 total). Coverage includes manual and automatic renewal, previous-plan activity, first connection, timeout eligibility, no timeout, unlimited duration, ordinary/template active plans, traffic carryover, and reset logging. Notification/node-sync calls and WireGuard allocation helpers were mocked in the temporary cases; database persistence and review queries used the real implementation. Ruff lint/format and
git diff --checkpassed.Only
app/db/crud/user.pyis changed; no test, documentation, dependency, or migration files are included.Summary by CodeRabbit