lot of new functionalities

This commit is contained in:
Arnaud Delcasse
2025-10-14 18:11:13 +02:00
parent a6f70a6e85
commit d992a7984f
164 changed files with 15113 additions and 9442 deletions

View File

@@ -0,0 +1,36 @@
package application
import (
"net/http"
"github.com/rs/zerolog/log"
)
func (h *Handler) SendSMSHTTPHandler() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
if r.Method != "POST" {
w.WriteHeader(http.StatusMethodNotAllowed)
return
}
referer := r.Referer()
if err := r.ParseForm(); err != nil {
log.Error().Err(err).Msg("Bad request")
w.WriteHeader(http.StatusBadRequest)
return
}
message := r.PostFormValue("message")
beneficiaryID := r.PostFormValue("beneficiaryid")
err := h.applicationHandler.SendSMS(r.Context(), beneficiaryID, message)
if err != nil {
log.Error().Err(err).Msg("error sending SMS")
http.Error(w, "Internal Server Error", http.StatusInternalServerError)
return
}
http.Redirect(w, r, referer, http.StatusFound)
}
}