delete subscription and store it in the delete
This commit is contained in:
parent
56c1b45f45
commit
372647b3b9
2
go.mod
2
go.mod
|
@ -8,7 +8,7 @@ go 1.18
|
|||
|
||||
// replace git.coopgo.io/coopgo-platform/fleets => ../../coopgo-platform/fleets/
|
||||
|
||||
// replace git.coopgo.io/coopgo-platform/agenda => ../../coopgo-platform/agenda/
|
||||
replace git.coopgo.io/coopgo-platform/agenda => ../../coopgo-platform/agenda/
|
||||
|
||||
// replace git.coopgo.io/coopgo-platform/emailing => ../../coopgo-platform/emailing/
|
||||
|
||||
|
|
|
@ -332,13 +332,46 @@ func contains(s []*agenda.Subscription, e string) bool {
|
|||
|
||||
///////////////////////////Delete subscriber///////////////////////////////
|
||||
func (h *ApplicationHandler) AgendaDeleteSubscribeEvent(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
vars := mux.Vars(r)
|
||||
eventid := vars["eventid"]
|
||||
eventId := vars["eventid"]
|
||||
subscribeid := vars["subscribeid"]
|
||||
fmt.Println(eventid)
|
||||
fmt.Println(subscribeid)
|
||||
h.Renderer.AgendaDeleteSubscribeEvent(w, r, eventid)
|
||||
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
|
||||
}
|
||||
}
|
||||
if r.Method == "POST" {
|
||||
request := &agenda.DeleteSubscriptionRequest{
|
||||
Subscriber: subscribeid,
|
||||
Eventid: eventId,
|
||||
Data: dd,
|
||||
}
|
||||
|
||||
_, err := h.services.GRPC.Agenda.DeleteSubscription(context.TODO(), request)
|
||||
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
http.Redirect(w, r, fmt.Sprintf("/app/agenda/%s", eventId), http.StatusFound)
|
||||
return
|
||||
}
|
||||
h.Renderer.AgendaDeleteSubscribeEvent(w, r, eventId)
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
|
|
Loading…
Reference in New Issue