diff --git a/bin/evening_detective_server b/bin/evening_detective_server index a982192..56606f1 100755 Binary files a/bin/evening_detective_server and b/bin/evening_detective_server differ diff --git a/internal/services/gameplay_service/finished_story_test.go b/internal/services/gameplay_service/finished_story_test.go index e4c7267..56c6cfa 100644 --- a/internal/services/gameplay_service/finished_story_test.go +++ b/internal/services/gameplay_service/finished_story_test.go @@ -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) diff --git a/internal/services/gameplay_service/service.go b/internal/services/gameplay_service/service.go index 9f850e0..b212f22 100644 --- a/internal/services/gameplay_service/service.go +++ b/internal/services/gameplay_service/service.go @@ -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.