Feat: end turn endpoint

This commit is contained in:
Grail Finder
2025-05-08 20:04:09 +03:00
parent 3cc2ecb93d
commit 8baf03595e
7 changed files with 51 additions and 6 deletions

View File

@ -70,9 +70,9 @@ func saveStateByCtx(ctx context.Context, state *models.UserState) error {
return saveState(username, state)
}
func saveFullInfoByUsername(username string, fi *models.FullInfo) error {
func saveFullInfo(fi *models.FullInfo) error {
// INFO: unfortunately working no transactions; so case are possible where first object is updated but the second is not
if err := saveState(username, fi.State); err != nil {
if err := saveState(fi.State.Username, fi.State); err != nil {
return err
}
if err := saveRoom(fi.Room); err != nil {
@ -194,7 +194,7 @@ func joinTeam(ctx context.Context, role, team string) (*models.FullInfo, error)
err := errors.New("uknown role:" + role)
return nil, err
}
if err := saveFullInfoByUsername(fi.State.Username, fi); err != nil {
if err := saveFullInfo(fi); err != nil {
return nil, err
}
return fi, nil