This commit is contained in:
2026-10-12 13:40:51 +07:00
parent 030ca56900
commit 0e20c3e151
3 changed files with 11 additions and 2 deletions
@@ -10,6 +10,7 @@ import (
"evening_detective_server/internal/modules/storytelling"
"evening_detective_server/internal/repos/games_repo"
"evening_detective_server/internal/repos/teams_repo"
"evening_detective_server/internal/services/game_model"
"github.com/jackc/pgx/v5/pgxpool"
)
@@ -56,6 +57,9 @@ func TestFinishedTeamStoryPostgres(t *testing.T) {
if !reflect.DeepEqual(story, &storytelling.Story{}) || len(actions) != 0 || game.Status != "finish" {
t.Fatalf("finished game exposed content or lost status: story=%+v game=%+v actions=%+v", story, game, actions)
}
if !reflect.DeepEqual(game.Teams, []*game_model.Team{{ID: "019a1234-5678-7abc-8def-000000000001", Name: "Team"}}) {
t.Fatalf("team identity missing or private data exposed: %+v", game.Teams)
}
}
if _, _, _, err := s.GetTeamActions(ctx, "019a1234-5678-7abc-8def-000000000001", "wrong"); !errors.Is(err, ErrTeamNotFound) {
t.Fatalf("password check bypassed: %v", err)
@@ -84,8 +84,13 @@ func (s *GameplayService) GetTeamActions(ctx context.Context, teamID string, pas
if err != nil {
return nil, nil, nil, mapGameplayError(err)
}
currentGame := game_model.MapGame(game, s.domain)
currentGame.Teams = []*game_model.Team{{
ID: team.ID,
Name: team.Name,
}}
if game.Status == "finish" {
return &storytelling.Story{}, game_model.MapGame(game, s.domain), nil, nil
return &storytelling.Story{}, currentGame, nil, nil
}
actions, err := s.actionsRepo.GetActionsByTeamID(ctx, teamID)
@@ -104,7 +109,7 @@ func (s *GameplayService) GetTeamActions(ctx context.Context, teamID string, pas
}
story := s.storyteller.GetStory(scenario.Story, codes)
filterTeamStory(story, game.Format)
return story, game_model.MapGame(game, s.domain), actions, nil
return story, currentGame, actions, nil
}
// AddTeamAction records an action performed by a team.