Skip to content

Commit

Permalink
add new stop
Browse files Browse the repository at this point in the history
  • Loading branch information
idprm committed Oct 11, 2024
1 parent f0e893e commit c5a6563
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cmd/seeder.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ func seederDB(db *gorm.DB) {
Category: ACT_CONFIRMATION,
Channel: ACT_SMS,
Name: SMS_FOLLOW_UNVALID_SUB,
Value: "Alerte SMS : Désolé, votre sélection n'est pas valide. Soumettez votre compétition ou le nom de votre équipe à {sc} pour obtenir toutes les informations. {price}{currency}/souscription",
Value: "SMS Alerte: Désolé, votre sélection n'est pas valide. Soumettez votre compétition ou le nom de votre équipe à {sc} pour obtenir toutes les informations. {price}{currency}/souscription",
},
{
Category: ACT_CONFIRMATION,
Expand Down
8 changes: 8 additions & 0 deletions internal/domain/entity/content.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ func (e *Content) SetValueSubFollowTeam(team, date, month, price, currency strin
e.Value = replacer.Replace(e.Value)
}

func (e *Content) SetValueSMSAlerteUnvalid(sc, price, currency string) {
replacer := strings.NewReplacer(
"{sc}", sc,
"{price}", price,
"{currency}", url.QueryEscape(currency))
e.Value = replacer.Replace(e.Value)
}

func (e *Content) SetValuePrediction(home, away, credit, price, currency string) {
replacer := strings.NewReplacer(
"{home}", url.QueryEscape(home),
Expand Down
18 changes: 17 additions & 1 deletion internal/handler/sms_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,12 @@ func (h *SMSHandler) Stop(category string) {
func (h *SMSHandler) Unvalid(v string) {
trxId := utils.GenerateTrxId()

content, err := h.getContent(v)
service, err := h.getServiceSMSAlerteDaily()
if err != nil {
log.Println(err.Error())
}

content, err := h.getContentSMSAlerteUnvalid(v, service)
if err != nil {
log.Println(err.Error())
}
Expand Down Expand Up @@ -1013,6 +1018,17 @@ func (h *SMSHandler) getContentFollowTeam(v string, service *entity.Service, tea
return h.contentService.GetFollowTeam(v, service, team)
}

func (h *SMSHandler) getContentSMSAlerteUnvalid(v string, service *entity.Service) (*entity.Content, error) {
if !h.contentService.IsContent(v) {
return &entity.Content{
Category: "CATEGORY",
Channel: "SMS",
Value: "SAMPLE_TEXT",
}, nil
}
return h.contentService.GetSMSAlerteUnvalid(v, service)
}

/**
** UNUSED
**/
Expand Down
10 changes: 10 additions & 0 deletions internal/services/content_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ type IContentService interface {
GetAllPaginate(*entity.Pagination) (*entity.Pagination, error)
GetFollowCompetition(string, *entity.Service, *entity.League) (*entity.Content, error)
GetFollowTeam(string, *entity.Service, *entity.Team) (*entity.Content, error)
GetSMSAlerteUnvalid(string, *entity.Service) (*entity.Content, error)
Get(string) (*entity.Content, error)
Save(*entity.Content) (*entity.Content, error)
Update(*entity.Content) (*entity.Content, error)
Expand Down Expand Up @@ -57,6 +58,15 @@ func (s *ContentService) GetFollowTeam(name string, service *entity.Service, tea
return c, nil
}

func (s *ContentService) GetSMSAlerteUnvalid(name string, service *entity.Service) (*entity.Content, error) {
c, err := s.contentRepo.Get(name)
if err != nil {
return nil, err
}
c.SetValueSMSAlerteUnvalid(service.ScSubMT, service.GetPriceToString(), service.GetCurrency())
return c, nil
}

func (s *ContentService) Get(name string) (*entity.Content, error) {
return s.contentRepo.Get(name)
}
Expand Down

0 comments on commit c5a6563

Please sign in to comment.