package application import ( "net/http" "git.coopgo.io/coopgo-apps/parcoursmob/utils/identification" "git.coopgo.io/coopgo-platform/emailing" "github.com/rs/zerolog/log" ) type Message struct { Content string } func (h *ApplicationHandler) SupportSend(w http.ResponseWriter, r *http.Request) { c := r.Context().Value(identification.ClaimsKey) if c == nil { log.Error().Msg("no current user claims") w.WriteHeader(http.StatusInternalServerError) return } current_user_claims := c.(map[string]any) comment := r.PostFormValue(("comment")) if r.Method == "POST" { user_email := current_user_claims["email"].(string) data := map[string]any{ "key": comment, "user": user_email, } log.Debug().Str("user_email", user_email).Msg("Sending message") if err := h.emailing.Send("support.request", "support@parcoursmob.fr", data, emailing.WithReplyTo(user_email), emailing.WithTLSOpportunistic()); err != nil { log.Error().Err(err).Msg("error sending email") w.WriteHeader(http.StatusInternalServerError) return } http.Redirect(w, r, "/app/", http.StatusFound) return } h.Renderer.SupportSend(w, r, comment, current_user_claims) }