Feat: create room
This commit is contained in:
		| @@ -75,6 +75,10 @@ func saveFullInfo(fi *models.FullInfo) error { | ||||
| 	if err := saveState(fi.State.Username, fi.State); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	// can room be nil? | ||||
| 	// if fi.Room == nil { | ||||
| 	// 	return nil | ||||
| 	// } | ||||
| 	if err := saveRoom(fi.Room); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| @@ -126,19 +130,24 @@ func getAllNames() []string { | ||||
| 	return names | ||||
| } | ||||
|  | ||||
| // 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 | ||||
| 	} | ||||
| 	resp.State = state | ||||
| 	if state.RoomID == "" { | ||||
| 		return resp, nil | ||||
| 	} | ||||
| 	room, err := getRoomByID(state.RoomID) | ||||
| 	if err != nil { | ||||
| 		log.Warn("failed to find room despite knowing room_id;", | ||||
| 			"room_id", state.RoomID) | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	resp := &models.FullInfo{ | ||||
| 		State: state, | ||||
| 		Room:  room, | ||||
| 	} | ||||
| 	resp.Room = room | ||||
| 	return resp, nil | ||||
| } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Grail Finder
					Grail Finder