Skip to content

Commit

Permalink
fixed webhook interactions blocking forever
Browse files Browse the repository at this point in the history
  • Loading branch information
topi314 committed Mar 28, 2021
1 parent 2505ff5 commit 7dd331d
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions internal/webhook_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,12 @@ func (h *webhookInteractionHandler) ServeHTTP(w http.ResponseWriter, r *http.Req
w.WriteHeader(http.StatusBadRequest)
}
c := make(chan interface{})
h.webhookServer.Disgo().EventManager().Handle(api.InteractionCreateWebhookEvent, rawBody, c)
go h.webhookServer.Disgo().EventManager().Handle(api.InteractionCreateWebhookEvent, rawBody, c)

response := <-c
w.WriteHeader(http.StatusOK)
w.Header().Set("Content-Type", "application/json")

err = json.NewEncoder(w).Encode(response)
err = json.NewEncoder(w).Encode(<-c)
if err != nil {
log.Errorf("error writing body: %s", err)
}
Expand Down

0 comments on commit 7dd331d

Please sign in to comment.