Enha: removing memcache [WIP]
This commit is contained in:
		| @@ -158,15 +158,17 @@ func getAllNames() []string { | ||||
| // can room exists without state? I think no | ||||
| func getFullInfoByCtx(ctx context.Context) (*models.FullInfo, error) { | ||||
| 	resp := &models.FullInfo{} | ||||
| 	state, err := getStateByCtx(ctx) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	// state, err := getStateByCtx(ctx) | ||||
| 	// if err != nil { | ||||
| 	// 	return nil, err | ||||
| 	// } | ||||
| 	state, err := getPlayerByCtx(ctx) | ||||
| 	resp.State = state | ||||
| 	if state.RoomID == "" { | ||||
| 		return resp, nil | ||||
| 	} | ||||
| 	room, err := getRoomByID(state.RoomID) | ||||
| 	// room, err := getRoomByID(state.RoomID) | ||||
| 	room, err := repo.GetRoomByID(ctx, state.RoomID) | ||||
| 	if err != nil { | ||||
| 		log.Warn("failed to find room despite knowing room_id;", | ||||
| 			"room_id", state.RoomID) | ||||
| @@ -176,6 +178,15 @@ func getFullInfoByCtx(ctx context.Context) (*models.FullInfo, error) { | ||||
| 	return resp, nil | ||||
| } | ||||
|  | ||||
| func getPlayerByCtx(ctx context.Context) (*models.Player, error) { | ||||
| 	username, ok := ctx.Value(models.CtxUsernameKey).(string) | ||||
| 	if !ok { | ||||
| 		log.Debug("no username in ctx") | ||||
| 		return &models.Player{}, errors.New("no username in ctx") | ||||
| 	} | ||||
| 	return repo.GetPlayerByName(username) | ||||
| } | ||||
|  | ||||
| // // DEPRECATED | ||||
| // func leaveRole(fi *models.FullInfo) { | ||||
| // 	fi.Room.RedTeam.Guessers = utils.RemoveFromSlice(fi.State.Username, fi.Room.RedTeam.Guessers) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Grail Finder
					Grail Finder