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
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////Delete subscriber///////////////////////////////
|
// /////////////////////////Delete subscriber///////////////////////////////
|
||||||
func (h *ApplicationHandler) AgendaDeleteSubscribeEvent(w http.ResponseWriter, r *http.Request) {
|
func (h *ApplicationHandler) AgendaDeleteSubscribeEvent(w http.ResponseWriter, r *http.Request) {
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
eventId := vars["eventid"]
|
eventId := vars["eventid"]
|
||||||
subscribeid := vars["subscribeid"]
|
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 {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := range resp.Event.Subscriptions {
|
current_user_token, current_user_claims, err := h.currentUser(r)
|
||||||
if resp.Event.Subscriptions[i].Subscriber == subscribeid {
|
if err != nil {
|
||||||
d := resp.Event.Subscriptions[i].Data
|
fmt.Println(err)
|
||||||
dd = d
|
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" {
|
if r.Method == "POST" {
|
||||||
request := &agenda.DeleteSubscriptionRequest{
|
request := &agenda.DeleteSubscriptionRequest{
|
||||||
Subscriber: subscribeid,
|
Subscriber: subscribeid,
|
||||||
Eventid: eventId,
|
Eventid: eventId,
|
||||||
Data: dd,
|
Data: datapb,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
_, err := h.services.GRPC.Agenda.DeleteSubscription(context.TODO(), request)
|
_, err := h.services.GRPC.Agenda.DeleteSubscription(context.TODO(), request)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue