generated from VLADIMIR/template
fix
This commit is contained in:
@@ -20,19 +20,24 @@ import (
|
||||
"github.com/jackc/pgx/v5"
|
||||
)
|
||||
|
||||
// ParticipationService handles team participation.
|
||||
type ParticipationService struct {
|
||||
teamsRepo *teams_repo.TeamsRepo
|
||||
appBaseURL string
|
||||
}
|
||||
|
||||
// NewParticipationService creates a participation service.
|
||||
func NewParticipationService(teamsRepo *teams_repo.TeamsRepo, appBaseURL string) *ParticipationService {
|
||||
return &ParticipationService{teamsRepo: teamsRepo, appBaseURL: appBaseURL}
|
||||
}
|
||||
|
||||
// GetParticipation returns participation data by token.
|
||||
func (s *ParticipationService) GetParticipation(ctx context.Context, token string) (*Participation, error) {
|
||||
p, err := s.teamsRepo.GetParticipation(ctx, token)
|
||||
return mapParticipation(p), mapParticipationError(err)
|
||||
}
|
||||
|
||||
// AnswerParticipation stores a team's final answer.
|
||||
func (s *ParticipationService) AnswerParticipation(ctx context.Context, token, answer string) (*Participation, error) {
|
||||
p, err := s.teamsRepo.AnswerParticipation(ctx, token, answer)
|
||||
return mapParticipation(p), mapParticipationError(err)
|
||||
@@ -76,6 +81,7 @@ func participationEmail(p *Participation, baseURL, token string, location *time.
|
||||
return email_sender.Message{To: p.Email, Subject: "Подтвердите участие в «Вечернем детективе»", Body: body, HTML: markup}
|
||||
}
|
||||
|
||||
// RunParticipationEmails sends pending participation emails.
|
||||
func (s *ParticipationService) RunParticipationEmails(ctx context.Context, sender email_sender.IEmailSender, secret, timezone string) {
|
||||
base, err := url.Parse(s.appBaseURL)
|
||||
if err != nil || base.Host == "" || (base.Scheme != "https" && base.Scheme != "http") || base.User != nil || base.RawQuery != "" || base.Fragment != "" || secret == "" {
|
||||
|
||||
Reference in New Issue
Block a user