generated from VLADIMIR/template
add email
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user