mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[PR #6500] [MERGED] fix(tgbot): show a disabled start-after-first-use client as days, not a 1969 date #6313
Labels
No labels
backlog
bug
clarification needed
documentation
duplicate
enhancement
github_actions
good first issue
invalid
javascript
New Feature
PR welcomed
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
MHSanaei/3x-ui#6313
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/MHSanaei/3x-ui/pull/6500
Author: @BlindMaster24
Created: 9/13/2026
Status: ✅ Merged
Merged: 9/13/2026
Merged by: @MHSanaei
Base:
main← Head:fix/tgbot-disabled-delayed-expiry📝 Commits (1)
14fa3fefix(tgbot): render a disabled start-after-first-use client as days📊 Changes
2 files changed (+63 additions, -3 deletions)
View changed files
📝
internal/web/service/tgbot/tgbot_client.go(+5 -3)➕
internal/web/service/tgbot/tgbot_client_expiry_test.go(+58 -0)📄 Description
Summary
Reorders the expiry branches in the Telegram bot's client card so a client whose expiry starts at first use (a negative
ExpiryTime) is reported in days even while the client is disabled.Why
Found by the automated review of #6498 (
fix(discord): report a start-after-first-use client as days, not unlimited), which flagged the Telegram card as the one surface still misreading the same value. It is pre-existing, so it came here instead of into that PR.The panel stores "starts after first connection, N days" as a negative expiry (
-2592000000for 30 days).clientInfoMsghad this order:time.Unix(-2592000, 0)is1969-12-02 04:00:00.flagalso stayed false, so the card labelled it Expire Date rather than Expire In.User story
-30 days— "starts at first use".📅 Expire Date: 1969-12-02 04:00:00, which reads as corrupt data rather than "30 days, starting when they first connect".The panel UI,
subscriptionExpiryFromClientandadjustTrafficsall key off the sign ofExpiryTime, and so doesBuildClientDraftMessagein this same file; this card and the Discord card were the two that did not — #6498 fixes the Discord side, which is where this finding came from.Type of change
Areas affected
How was this tested?
New
TestClientInfoShowsStartAfterFirstUseWhenDisabled(internal/web/service/tgbot/tgbot_client_expiry_test.go) builds aClientTrafficwithEnable: falseandExpiryTime: -30 * 24 * 60 * 60000, renders the card throughclientInfoMsg, and asserts it containsExpire In: 30 Daysand no1969.On the code before this commit the assertion reads
client info = "📧 Email: trial@example.com\r\n📅 Expire Date: 1969-12-02 04:00:00\r\n"; with the sign branch moved up it passes. The test installs a real go-i18n bundle for the four keys the card prints, becauseI18nBotreturns the bare key when no localizer is set.Behaviour is unchanged for every other combination: only
ExpiryTime < 0moves; positive-and-far, positive-and-near, enabled and disabled all still take the branches they took before.Honesty about local verification
I could not build or run the tests on this machine: the SQLite driver is CGo and there is no C compiler here (
CGO_ENABLED=0cannot buildinternal/database, so thetgbotpackage does not compile either).gofmtis clean, and the build/test verdict here comes from CI, not from a local run. I reverted the fix and re-read the assertion path rather than executing it.Screenshots / recordings
N/A — Telegram message text, covered by the test above.
Breaking changes
None.
Checklist
go build ./...and the test suite pass locally.npm run lint,npm run typecheck, andnpm run buildpass. (no frontend change in this PR)🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.