mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[PR #6604] [MERGED] fix(tgbot): scope the add-client wizard to the admin, not the chat #6372
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#6372
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/6604
Author: @sdhfsl
Created: 9/19/2026
Status: ✅ Merged
Merged: 9/26/2026
Merged by: @MHSanaei
Base:
main← Head:fix-bot-group-draft📝 Commits (8)
959e6fdfix(panel): accept 2FA codes from adjacent TOTP windowsf3096bbfix(panel): share TOTP skew tolerance with VerifyTwoFactorCode198ac75Merge branch 'main' into mainacb0297Merge branch 'MHSanaei:main' into main35b92a1Merge branch 'MHSanaei:main' into main4687a85fix(tgbot): scope the add-client wizard to the admin, not the chat27567aftest(tgbot): pin the sender key the typed wizard steps read9a34cf3Merge branch 'main' into fix-bot-group-draft📊 Changes
7 files changed (+177 additions, -51 deletions)
View changed files
📝
internal/web/service/tgbot/tgbot.go(+42 -20)📝
internal/web/service/tgbot/tgbot_add_client_expiry_test.go(+2 -2)➕
internal/web/service/tgbot/tgbot_client_draft_per_admin_test.go(+102 -0)📝
internal/web/service/tgbot/tgbot_client_draft_per_chat_test.go(+2 -2)📝
internal/web/service/tgbot/tgbot_delete_after_test.go(+2 -2)📝
internal/web/service/tgbot/tgbot_draft_render_test.go(+4 -4)📝
internal/web/service/tgbot/tgbot_router.go(+23 -21)📄 Description
Summary
Keys the add-client wizard's draft and conversation state by
(chat, user)instead of by chat alone, so two admins in one group chat no longer fill in one client between them.Why
Closes #6593.
clientDraftsanduserStateStorewere keyed by chat id only (internal/web/service/tgbot/tgbot.go). That fixed two admins in different chats, but in a group chat both admins are in the same chat, so they still reached one*clientDraftand one wizard step: the second admin's wizard opened pre-filled with the first one's email and limits, and whichever of them tapped a control last decided what the other created.A private chat is unaffected — its chat id and user id are equal, so the new key matches what the chat id alone used to be. A message with no sender (a channel post) keys to user 0, an id no admin can hold.
Type of change
Areas affected
How was this tested?
New regression test
TestAddClientDraftIsPerAdminInGroupChat(internal/web/service/tgbot/tgbot_client_draft_per_admin_test.go): two admins tapadd_client_toin the same group chat (same chat id, differentFrom.ID) and then both render their card again.Before the change it fails with the defect the issue describes:
After it passes, and it also pins the second half of the issue — the step each admin is on is their own: after admin A taps
add_client_ch_default_email, A isawaiting_emailand B has no step at all.Commands run:
go test ./internal/web/service/tgbot/— passgo test -race -shuffle=on -count=1 ./internal/web/service/tgbot/— pass, no data racegofmt -l internal/web/service/tgbot/— cleango build ./...— passes for every package except the root andinternal/web, which needfrontend/dist(gitignored). This is unrelated to the change and reproduces on a cleanmainin the same checkout.go test ./...— the tgbot package andinternal/web/servicepass. On my Windows box five packages fail for environment reasons: root andinternal/web(all:dist: no matching files found),internal/amneziawgnet(tunnel tests needing real network),internal/crypto/nodetoken(TestFileKeySourceRejectsLoosePerms— no POSIX permission bits),internal/loggerandinternal/web/service/panel(one timing and one env-var test each). I re-ran each of these on a clean checkout without this change and they fail identically, so none of them is a regression from this PR.Existing tests that used the old key were updated to the new one (
tgbot_add_client_expiry_test.go,tgbot_client_draft_per_chat_test.go,tgbot_delete_after_test.go,tgbot_draft_render_test.go); no assertions were weakened.Screenshots / recordings
N/A — no UI change.
Breaking changes
None. The wizard's behavior in private chats and the callback data are unchanged.
Checklist
go build ./...and the test suite pass locally. (see note above on the Windows-only environment failures)npm run lint,npm run typecheck, andnpm run buildpass. — N/A, no frontend change.Scope note
The issue also mentions that both admins in a group still see and can tap the same card, so either admin's tap re-renders the other's inline keyboard. This PR does not change that: making the card itself per-admin means deciding where a group's wizard card should live (e.g. moving the flow to a private chat), which is a UX decision the issue author explicitly left open. The change here is limited to the draft and the step, which is the scope the issue's Notes describe.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.