Feat: create room

This commit is contained in:
Grail Finder
2025-05-09 11:24:33 +03:00
parent e20118acea
commit 2b4bf2ec29
6 changed files with 39 additions and 18 deletions

View File

@ -23,8 +23,16 @@ func HandleCreateRoom(w http.ResponseWriter, r *http.Request) {
return
}
ctx := context.WithValue(r.Context(), "current_room", room.ID)
ctx, err = updateRoomInSession(ctx, room.ID)
fi, err := getFullInfoByCtx(ctx)
if err != nil {
msg := "failed to get full info from ctx"
log.Error(msg, "error", err)
abortWithError(w, msg)
return
}
fi.State.RoomID = room.ID
fi.Room = room
if err := saveFullInfo(fi); err != nil {
msg := "failed to set current room to session"
log.Error(msg, "error", err)
abortWithError(w, msg)
@ -41,7 +49,7 @@ func HandleCreateRoom(w http.ResponseWriter, r *http.Request) {
abortWithError(w, err.Error())
return
}
tmpl.ExecuteTemplate(w, "base", nil)
tmpl.ExecuteTemplate(w, "base", fi)
}
func HandleRoomEnter(w http.ResponseWriter, r *http.Request) {