parcoursmob/handlers/application/support.go

41 lines
897 B
Go
Raw Normal View History

2022-10-31 09:39:43 +00:00
package application
import (
"fmt"
"net/http"
"git.coopgo.io/coopgo-apps/parcoursmob/utils/identification"
)
type Message struct {
Content string
}
func (h *ApplicationHandler) SupportSend(w http.ResponseWriter, r *http.Request) {
c := r.Context().Value(identification.ClaimsKey)
if c == nil {
fmt.Println("no current user claims")
w.WriteHeader(http.StatusInternalServerError)
return
}
current_user_claims := c.(map[string]any)
comment := r.PostFormValue(("comment"))
if r.Method == "POST" {
data := map[string]any{
"key": comment,
"user": current_user_claims["email"],
}
2022-11-01 10:54:59 +00:00
if err := h.emailing.Send("support.request", "support@parcoursmob.fr", data); err != nil {
2022-10-31 09:39:43 +00:00
fmt.Println(err)
2022-11-01 10:54:59 +00:00
w.WriteHeader(http.StatusInternalServerError)
2022-10-31 09:39:43 +00:00
}
http.Redirect(w, r, "/app/", http.StatusFound)
return
}
h.Renderer.SupportSend(w, r, comment, current_user_claims)
}