feat: retrieve session and room in HandleShowColor
This commit is contained in:

committed by
Grail Finder (aider)

parent
b135356d3f
commit
444f10ea7e
@ -28,6 +28,16 @@ func HandleHideCreateForm(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
func HandleShowColor(w http.ResponseWriter, r *http.Request) {
|
func HandleShowColor(w http.ResponseWriter, r *http.Request) {
|
||||||
word := r.URL.Query().Get("word")
|
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]
|
color, exists := roundWords[word]
|
||||||
log.Debug("got show-color request", "word", word, "color", color)
|
log.Debug("got show-color request", "word", word, "color", color)
|
||||||
if !exists {
|
if !exists {
|
||||||
|
Reference in New Issue
Block a user