mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[PR #6498] [MERGED] fix(discord): report a start-after-first-use client as days, not unlimited #6310
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#6310
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/6498
Author: @BlindMaster24
Created: 9/13/2026
Status: ✅ Merged
Merged: 9/13/2026
Merged by: @MHSanaei
Base:
main← Head:fix/discord-usage-delayed-expiry📝 Commits (1)
efc6639fix(discord): report a start-after-first-use client as days, not unlimited📊 Changes
2 files changed (+117 additions, -1 deletions)
View changed files
📝
internal/web/service/discord/gateway.go(+6 -1)➕
internal/web/service/discord/gateway_delayed_expiry_test.go(+111 -0)📄 Description
Summary
!usagenow renders a client whose expiry is the "Start After First Use" duration asN Days, the same way the panel and the Telegram bot already render it, instead of labelling itUnlimited.Why
sendUsage(internal/web/service/discord/gateway.go) started fromtr("unlimited")and only replaced it for a positive timestamp:A negative
expiryTimeis not "no expiry" in this panel — it is the Start After First Use mode, stored as the duration negated and turned into an absolute deadline byadjustTrafficson the client's first traffic tick (internal/web/service/inbound_traffic.go, theUPDATE ... WHERE expiry_time < 0block). The Telegram bot renders exactly this value as days (internal/web/service/tgbot/tgbot_client.go, theclient_ExpiryTime < 0case), and the frontend edits it asdelayedStart(Start After First Use,internal/web/translation/en-US.json). So the Discord embed was the one surface telling an operator that a client which does expire never will.Operator's story: they hand out 30-day trial keys with "Start After First Use" so the clock starts when the customer first connects. Checking one with
!usage trial@example.com, the embed readsExpiry: Unlimitedwhile the panel's client list shows the same client counting down — the two disagree, and the safest reading of the Discord answer ("this key never expires") is the wrong one.Type of change
Areas affected
internal/web/service/discord, the Discord bot added in #6486)How was this tested?
New
TestUsageExpiryForDelayedStartdrives!usage <email>throughhandleMessageand the REST client against anhttptestserver, and reads the expiry field of the embed that would reach Discord.-2592000000ms — what the panel writes for Start After First Use: 30 days — must come back as30 Days. Without the change it comes back asUnlimited:delayed start shows "Unlimited", want "30 Days".4102444800000ms) must still come back as a formatted date, so the new branch does not swallow the case that already worked.The whole
internal/web/service/discordpackage suite passes with the change, andgo vetis clean for the package.Caveat, stated rather than glossed: this machine has no C compiler, so the CGo
mattn/go-sqlite3driver cannot build here; the suite above ran through a local pure-Go SQLite build of the driver, and CI is the authoritative run.Screenshots / recordings
N/A — no UI change.
Breaking changes
None. The value shown for a delayed-start client changes from a wrong label to the one the rest of the panel already uses; no key, setting or endpoint is touched, and
tgbot.daysis reused rather than a new i18n key added.Checklist
go build ./...and the test suite pass locally. (no C compiler here — CI verifies the CGo build)npm run lint,npm run typecheck, andnpm run buildpass.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.