46 lines
1000 B
Go
46 lines
1000 B
Go
|
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"],
|
||
|
}
|
||
|
|
||
|
if err := h.emailing.Send("onboarding.Support_email", "support@parcoursmob.fr", data); err != nil {
|
||
|
fmt.Println(err)
|
||
|
fmt.Println("error")
|
||
|
}
|
||
|
fmt.Println("success")
|
||
|
http.Redirect(w, r, "/app/", http.StatusFound)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
fmt.Println("comment page!")
|
||
|
fmt.Println(comment)
|
||
|
fmt.Print(current_user_claims["email"])
|
||
|
h.Renderer.SupportSend(w, r, comment, current_user_claims)
|
||
|
}
|