add 'suscribed_by' in Data on DB
This commit is contained in:
parent
696cd1d87f
commit
11851fec61
|
@ -335,26 +335,33 @@ func (h *ApplicationHandler) AgendaDeleteSubscribeEvent(w http.ResponseWriter, r
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
eventId := vars["eventid"]
|
eventId := vars["eventid"]
|
||||||
subscribeid := vars["subscribeid"]
|
subscribeid := vars["subscribeid"]
|
||||||
|
s_b_id := ""
|
||||||
|
s_b_name := ""
|
||||||
|
s_b_group_id := ""
|
||||||
|
s_b_group_name := ""
|
||||||
|
request := &agenda.GetEventRequest{
|
||||||
|
Id: eventId,
|
||||||
|
}
|
||||||
|
|
||||||
/////////////////////////Test ajout motif///////////////////////////////
|
resp, err := h.services.GRPC.Agenda.GetEvent(context.TODO(), request)
|
||||||
// dd, _ := structpb.NewStruct(map[string]any{})
|
if err != nil {
|
||||||
// request := &agenda.GetEventRequest{
|
fmt.Println(err)
|
||||||
// Id: eventId,
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
// }
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// resp, err := h.services.GRPC.Agenda.GetEvent(context.TODO(), request)
|
for i := range resp.Event.Subscriptions {
|
||||||
// if err != nil {
|
if resp.Event.Subscriptions[i].Subscriber == subscribeid {
|
||||||
// fmt.Println(err)
|
subscribed_by_id := resp.Event.Subscriptions[i].Data.Fields["subscribed_by"].GetStructValue().Fields["user"].GetStructValue().Fields["id"].GetStringValue()
|
||||||
// w.WriteHeader(http.StatusInternalServerError)
|
s_b_id = subscribed_by_id
|
||||||
// return
|
subscribed_by_name := resp.Event.Subscriptions[i].Data.Fields["subscribed_by"].GetStructValue().Fields["user"].GetStructValue().Fields["display_name"].GetStringValue()
|
||||||
// }
|
s_b_name = subscribed_by_name
|
||||||
|
subscribed_by_group_id := resp.Event.Subscriptions[i].Data.Fields["subscribed_by"].GetStructValue().Fields["group"].GetStructValue().Fields["id"].GetStringValue()
|
||||||
// for i := range resp.Event.Subscriptions {
|
s_b_group_id = subscribed_by_group_id
|
||||||
// if resp.Event.Subscriptions[i].Subscriber == subscribeid {
|
subscribed_by_group_name := resp.Event.Subscriptions[i].Data.Fields["subscribed_by"].GetStructValue().Fields["group"].GetStructValue().Fields["name"].GetStringValue()
|
||||||
// d := resp.Event.Subscriptions[i].Data
|
s_b_group_name = subscribed_by_group_name
|
||||||
// dd = d
|
}
|
||||||
// }
|
}
|
||||||
// }
|
|
||||||
|
|
||||||
current_group, err := h.currentGroup(r)
|
current_group, err := h.currentGroup(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -371,6 +378,16 @@ func (h *ApplicationHandler) AgendaDeleteSubscribeEvent(w http.ResponseWriter, r
|
||||||
}
|
}
|
||||||
|
|
||||||
data := map[string]any{
|
data := map[string]any{
|
||||||
|
"subscribed_by": map[string]any{
|
||||||
|
"user": map[string]any{
|
||||||
|
"id": s_b_id,
|
||||||
|
"display_name": s_b_name,
|
||||||
|
},
|
||||||
|
"group": map[string]any{
|
||||||
|
"id": s_b_group_id,
|
||||||
|
"name": s_b_group_name,
|
||||||
|
},
|
||||||
|
},
|
||||||
"unsubscribed_by": map[string]any{
|
"unsubscribed_by": map[string]any{
|
||||||
"user": map[string]any{
|
"user": map[string]any{
|
||||||
"id": current_user_token.Subject,
|
"id": current_user_token.Subject,
|
||||||
|
@ -383,6 +400,7 @@ func (h *ApplicationHandler) AgendaDeleteSubscribeEvent(w http.ResponseWriter, r
|
||||||
},
|
},
|
||||||
"motif": r.FormValue("motif"),
|
"motif": r.FormValue("motif"),
|
||||||
}
|
}
|
||||||
|
|
||||||
datapb, err := structpb.NewStruct(data)
|
datapb, err := structpb.NewStruct(data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
|
@ -397,8 +415,6 @@ func (h *ApplicationHandler) AgendaDeleteSubscribeEvent(w http.ResponseWriter, r
|
||||||
Data: datapb,
|
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