feat: retrieve session and room in HandleShowColor

This commit is contained in:
Grail Finder
2025-05-03 12:16:43 +03:00
committed by Grail Finder (aider)
parent b135356d3f
commit 444f10ea7e

View File

@ -28,6 +28,16 @@ func HandleHideCreateForm(w http.ResponseWriter, r *http.Request) {
func HandleShowColor(w http.ResponseWriter, r *http.Request) {
word := r.URL.Query().Get("word")
ctx := r.Context()
session, ok := ctx.Value(models.CtxSessionKey).(models.Session)
if !ok {
// trying to get color without a session -> error
}
// get room by room-id
room, err := getRoomByID(session.CurrentRoom)
if err != nil {
// handle err; ai!
}
color, exists := roundWords[word]
log.Debug("got show-color request", "word", word, "color", color)
if !exists {