add 'Motif' in DB
This commit is contained in:
parent
372647b3b9
commit
696cd1d87f
|
@ -330,36 +330,75 @@ func contains(s []*agenda.Subscription, e string) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
///////////////////////////Delete subscriber///////////////////////////////
|
||||
// /////////////////////////Delete subscriber///////////////////////////////
|
||||
func (h *ApplicationHandler) AgendaDeleteSubscribeEvent(w http.ResponseWriter, r *http.Request) {
|
||||
vars := mux.Vars(r)
|
||||
eventId := vars["eventid"]
|
||||
subscribeid := vars["subscribeid"]
|
||||
dd, _ := structpb.NewStruct(map[string]any{})
|
||||
request := &agenda.GetEventRequest{
|
||||
Id: eventId,
|
||||
}
|
||||
|
||||
resp, err := h.services.GRPC.Agenda.GetEvent(context.TODO(), request)
|
||||
/////////////////////////Test ajout motif///////////////////////////////
|
||||
// dd, _ := structpb.NewStruct(map[string]any{})
|
||||
// request := &agenda.GetEventRequest{
|
||||
// Id: eventId,
|
||||
// }
|
||||
|
||||
// resp, err := h.services.GRPC.Agenda.GetEvent(context.TODO(), request)
|
||||
// if err != nil {
|
||||
// fmt.Println(err)
|
||||
// w.WriteHeader(http.StatusInternalServerError)
|
||||
// return
|
||||
// }
|
||||
|
||||
// for i := range resp.Event.Subscriptions {
|
||||
// if resp.Event.Subscriptions[i].Subscriber == subscribeid {
|
||||
// d := resp.Event.Subscriptions[i].Data
|
||||
// dd = d
|
||||
// }
|
||||
// }
|
||||
|
||||
current_group, err := h.currentGroup(r)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
for i := range resp.Event.Subscriptions {
|
||||
if resp.Event.Subscriptions[i].Subscriber == subscribeid {
|
||||
d := resp.Event.Subscriptions[i].Data
|
||||
dd = d
|
||||
}
|
||||
current_user_token, current_user_claims, err := h.currentUser(r)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
data := map[string]any{
|
||||
"unsubscribed_by": map[string]any{
|
||||
"user": map[string]any{
|
||||
"id": current_user_token.Subject,
|
||||
"display_name": current_user_claims["display_name"],
|
||||
},
|
||||
"group": map[string]any{
|
||||
"id": current_group.ID,
|
||||
"name": current_group.Data["name"],
|
||||
},
|
||||
},
|
||||
"motif": r.FormValue("motif"),
|
||||
}
|
||||
datapb, err := structpb.NewStruct(data)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
if r.Method == "POST" {
|
||||
request := &agenda.DeleteSubscriptionRequest{
|
||||
Subscriber: subscribeid,
|
||||
Eventid: eventId,
|
||||
Data: dd,
|
||||
Data: datapb,
|
||||
}
|
||||
|
||||
|
||||
|
||||
_, err := h.services.GRPC.Agenda.DeleteSubscription(context.TODO(), request)
|
||||
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue