add email

This commit is contained in:
2026-09-16 04:07:34 +07:00
parent b9afada40a
commit 99724058eb
10 changed files with 71 additions and 11 deletions
+7 -1
View File
@@ -15,6 +15,7 @@ import (
"evening_detective_server/internal/repos/team_answers_repo"
"evening_detective_server/internal/repos/teams_repo"
"evening_detective_server/internal/services/scenarios_service"
"strings"
"time"
)
@@ -217,7 +218,12 @@ func (s *GameService) AddTeam(
creatorId int,
gameId int,
name string,
captainEmail string,
) (*Team, error) {
captainEmail = strings.TrimSpace(captainEmail)
if captainEmail != "" && !validCaptainEmail(captainEmail) {
return nil, errors.New("Укажите корректную почту капитана")
}
password, err := s.passwordGenerator.Generate()
if err != nil {
return nil, err
@@ -226,7 +232,7 @@ func (s *GameService) AddTeam(
if err != nil {
return nil, err
}
id, err := s.teamsRepo.AddTeamWithParticipation(ctx, creatorId, gameId, name, password, !time.Now().Before(game.StartAt.Add(-24*time.Hour)))
id, err := s.teamsRepo.AddTeamWithParticipation(ctx, creatorId, gameId, name, password, captainEmail, !time.Now().Before(game.StartAt.Add(-24*time.Hour)))
if err != nil {
return nil, err
}