Ajout d'un numero identifiable pour pouvoir reproduire une erreur de numéro invalide cote powow #1

This commit is contained in:
2021-05-04 15:33:36 +02:00
parent 91d736cc82
commit 12d61f3e89
4 changed files with 8636 additions and 176 deletions

View File

@ -81,16 +81,6 @@ func handlePowowEntrypoint(w http.ResponseWriter, r *http.Request) {
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
}
//data, err := ioutil.ReadAll(r.Body)
//if err != nil {
// logger.Error(ctx, "could not read body", logger.E(errors.WithStack(err)))
// http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
// return
//}
//defer r.Body.Close()
pr := &PowowRequest{
Payload: make(map[string]interface{}),
}
@ -131,26 +121,12 @@ func handlePowowEntrypoint(w http.ResponseWriter, r *http.Request) {
}
pr.Payload = map[string]interface{}{
"SmsID": smsid,
"MobilePhoneNumber": r.FormValue("MobilePhoneNumber"),
"MobilePhoneNumber": strings.TrimSpace(r.FormValue("MobilePhoneNumber")),
"TimeToSend": r.FormValue("TimeToSend"),
"CustomData": customData,
}
}
//if err := json.Unmarshal(data, pr); err != nil {
// logger.Error(ctx, "could not parse request", logger.E(errors.WithStack(err)))
// http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
// return
//}
//if err := json.Unmarshal(data, &pr.Payload); err != nil {
// logger.Error(ctx, "could not parse request payload", logger.E(errors.WithStack(err)))
// http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
// return
//}
// Authenticate user
if conf.Powow.APIKey != pr.APIKey {
res := &PowowResponse{
@ -163,6 +139,20 @@ func handlePowowEntrypoint(w http.ResponseWriter, r *http.Request) {
return
}
// If phone number must return an error
spew.Dump(conf.Powow.InvalidPhoneNumber)
spew.Dump(pr.Payload["MobilePhoneNumber"])
if conf.Powow.InvalidPhoneNumber == pr.Payload["MobilePhoneNumber"] {
res := &PowowResponse{
Success: false,
ErrorCode: map[int]ErrorCode{0: ErrorCodeTransactionSMSSendInvalidMobilePhoneNumber},
}
sendPowowResponse(w, res)
return
}
// Handle Powow command
switch pr.Command {
case CommandTransactionalSMSSend: