fix(tgbot): scope the add-client wizard to the admin, not the chat (#6604)

Two admins in one group chat shared one draft and one wizard step: clientDrafts and userStateStore were keyed by chat id alone, so the second admin's wizard opened on the first one's email and limits, and whichever of them tapped a control last decided what the other created.

Key both stores by (chat, user) instead. A private chat is unaffected: its two ids are equal, so the key matches what the chat alone used to be. A message with no sender (a channel post) keys to user 0, which no admin holds.

Fixes #6593.
This commit is contained in:
sdhfsl
2026-09-27 02:31:39 +08:00
committed by GitHub
parent 3b9ca47a4e
commit ee2ff48c81
7 changed files with 179 additions and 53 deletions
@@ -7,12 +7,12 @@ func TestDeleteMessageAfterDelayKeepsUserState(t *testing.T) {
t.Cleanup(userStateMgr.reset)
const chatID = int64(4242)
userStateMgr.set(chatID, "awaiting_comment")
userStateMgr.set(chatUser{chatID: chatID, userID: 1}, "awaiting_comment")
tg := &Tgbot{}
tg.deleteMessageAfterDelay(chatID, 1, 0)
if st, ok := userStateMgr.get(chatID); !ok || st != "awaiting_comment" {
if st, ok := userStateMgr.get(chatUser{chatID: chatID, userID: 1}); !ok || st != "awaiting_comment" {
t.Fatalf("delayed message deletion cleared the conversation state: got (%q, %v), want (%q, true)", st, ok, "awaiting_comment")
}
}