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)
|
||||
eventId := vars["eventid"]
|
||||
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///////////////////////////////
|
||||
// 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
|
||||
}
|
||||
|
||||
// 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
|
||||
// }
|
||||
// }
|
||||
for i := range resp.Event.Subscriptions {
|
||||
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()
|
||||
s_b_id = subscribed_by_id
|
||||
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()
|
||||
s_b_group_id = subscribed_by_group_id
|
||||
subscribed_by_group_name := resp.Event.Subscriptions[i].Data.Fields["subscribed_by"].GetStructValue().Fields["group"].GetStructValue().Fields["name"].GetStringValue()
|
||||
s_b_group_name = subscribed_by_group_name
|
||||
}
|
||||
}
|
||||
|
||||
current_group, err := h.currentGroup(r)
|
||||
if err != nil {
|
||||
|
@ -371,6 +378,16 @@ func (h *ApplicationHandler) AgendaDeleteSubscribeEvent(w http.ResponseWriter, r
|
|||
}
|
||||
|
||||
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{
|
||||
"user": map[string]any{
|
||||
"id": current_user_token.Subject,
|
||||
|
@ -383,6 +400,7 @@ func (h *ApplicationHandler) AgendaDeleteSubscribeEvent(w http.ResponseWriter, r
|
|||
},
|
||||
"motif": r.FormValue("motif"),
|
||||
}
|
||||
|
||||
datapb, err := structpb.NewStruct(data)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
|
@ -397,8 +415,6 @@ func (h *ApplicationHandler) AgendaDeleteSubscribeEvent(w http.ResponseWriter, r
|
|||
Data: datapb,
|
||||
}
|
||||
|
||||
|
||||
|
||||
_, err := h.services.GRPC.Agenda.DeleteSubscription(context.TODO(), request)
|
||||
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue