sending mail to the prescripteur
This commit is contained in:
parent
193f5dfb6f
commit
f698891865
|
@ -232,6 +232,7 @@ func (h *ApplicationHandler) AgendaSubscribeEvent(w http.ResponseWriter, r *http
|
|||
"user": map[string]any{
|
||||
"id": current_user_token.Subject,
|
||||
"display_name": current_user_claims["first_name"].(string) + " " + current_user_claims["last_name"].(string),
|
||||
"email": current_user_claims["email"].(string),
|
||||
},
|
||||
"group": map[string]any{
|
||||
"id": current_group.ID,
|
||||
|
@ -338,6 +339,7 @@ func (h *ApplicationHandler) AgendaDeleteSubscribeEvent(w http.ResponseWriter, r
|
|||
subscribeid := vars["subscribeid"]
|
||||
s_b_id := ""
|
||||
s_b_name := ""
|
||||
s_b_email := ""
|
||||
s_b_group_id := ""
|
||||
s_b_group_name := ""
|
||||
request := &agenda.GetEventRequest{
|
||||
|
@ -355,10 +357,12 @@ func (h *ApplicationHandler) AgendaDeleteSubscribeEvent(w http.ResponseWriter, r
|
|||
if resp.Event.Subscriptions[i].Subscriber == subscribeid {
|
||||
subscribed_by_id := resp.Event.Subscriptions[i].Data.Fields["subscribed_by"].GetStructValue().Fields["user"].GetStructValue().Fields["id"].GetStringValue()
|
||||
subscribed_by_name := resp.Event.Subscriptions[i].Data.Fields["subscribed_by"].GetStructValue().Fields["user"].GetStructValue().Fields["display_name"].GetStringValue()
|
||||
subscribed_by_email := resp.Event.Subscriptions[i].Data.Fields["subscribed_by"].GetStructValue().Fields["user"].GetStructValue().Fields["email"].GetStringValue()
|
||||
subscribed_by_group_id := resp.Event.Subscriptions[i].Data.Fields["subscribed_by"].GetStructValue().Fields["group"].GetStructValue().Fields["id"].GetStringValue()
|
||||
subscribed_by_group_name := resp.Event.Subscriptions[i].Data.Fields["subscribed_by"].GetStructValue().Fields["group"].GetStructValue().Fields["name"].GetStringValue()
|
||||
s_b_id = subscribed_by_id
|
||||
s_b_name = subscribed_by_name
|
||||
s_b_email = subscribed_by_email
|
||||
s_b_group_id = subscribed_by_group_id
|
||||
s_b_group_name = subscribed_by_group_name
|
||||
}
|
||||
|
@ -383,6 +387,7 @@ func (h *ApplicationHandler) AgendaDeleteSubscribeEvent(w http.ResponseWriter, r
|
|||
"user": map[string]any{
|
||||
"id": s_b_id,
|
||||
"display_name": s_b_name,
|
||||
"email": s_b_email,
|
||||
},
|
||||
"group": map[string]any{
|
||||
"id": s_b_group_id,
|
||||
|
@ -393,6 +398,7 @@ func (h *ApplicationHandler) AgendaDeleteSubscribeEvent(w http.ResponseWriter, r
|
|||
"user": map[string]any{
|
||||
"id": current_user_token.Subject,
|
||||
"display_name": current_user_claims["first_name"].(string) + " " + current_user_claims["last_name"].(string),
|
||||
"email": current_user_claims["email"],
|
||||
},
|
||||
"group": map[string]any{
|
||||
"id": current_group.ID,
|
||||
|
@ -416,6 +422,15 @@ func (h *ApplicationHandler) AgendaDeleteSubscribeEvent(w http.ResponseWriter, r
|
|||
Data: datapb,
|
||||
}
|
||||
|
||||
data := map[string]any{
|
||||
"key": r.FormValue("motif"),
|
||||
"user": current_user_claims["email"],
|
||||
}
|
||||
|
||||
// récupérer l'adresse mail de l'utilisateur qui a créé l'événement
|
||||
mail := s_b_email;
|
||||
fmt.Println(mail)
|
||||
|
||||
_, err := h.services.GRPC.Agenda.DeleteSubscription(context.TODO(), request)
|
||||
|
||||
if err != nil {
|
||||
|
@ -424,6 +439,12 @@ func (h *ApplicationHandler) AgendaDeleteSubscribeEvent(w http.ResponseWriter, r
|
|||
return
|
||||
}
|
||||
|
||||
if err := h.emailing.Send("delete_subscriber.request", mail, data); err != nil {
|
||||
fmt.Println(err)
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
http.Redirect(w, r, fmt.Sprintf("/app/agenda/%s", eventId), http.StatusFound)
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue