mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-10-06 22:22:08 +03:00
ee2ff48c81
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.
19 lines
550 B
Go
19 lines
550 B
Go
package tgbot
|
|
|
|
import "testing"
|
|
|
|
func TestDeleteMessageAfterDelayKeepsUserState(t *testing.T) {
|
|
userStateMgr.reset()
|
|
t.Cleanup(userStateMgr.reset)
|
|
|
|
const chatID = int64(4242)
|
|
userStateMgr.set(chatUser{chatID: chatID, userID: 1}, "awaiting_comment")
|
|
|
|
tg := &Tgbot{}
|
|
tg.deleteMessageAfterDelay(chatID, 1, 0)
|
|
|
|
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")
|
|
}
|
|
}
|