Skip to content

Commit

Permalink
Merge pull request #49 from Quiq/main
Browse files Browse the repository at this point in the history
Adding room_name query arg back so it is flexible to use. Also for backward compatibility.
  • Loading branch information
mr-karan authored Aug 6, 2022
2 parents e2fdfdb + 38e928e commit 1b1b826
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions cmd/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,15 @@ func handleDispatchNotif(w http.ResponseWriter, r *http.Request) {
return
}

app.lo.WithField("receiver", payload.Receiver).Info("dispatching new alert")
roomName := r.URL.Query().Get("room_name")
if roomName == "" {
roomName = payload.Receiver
}

app.lo.WithField("receiver", roomName).Info("dispatching new alert")

// Dispatch a list of alerts via Notifier.
if err := app.notifier.Dispatch(payload.Alerts, payload.Receiver); err != nil {
if err := app.notifier.Dispatch(payload.Alerts, roomName); err != nil {
app.lo.WithError(err).Error("error dispatching alerts")
app.metrics.Increment(`http_request_errors_total{handler="dispatch"}`)
sendErrorResponse(w, "Error dispatching alerts.", http.StatusInternalServerError, nil)
Expand Down

0 comments on commit 1b1b826

Please sign in to comment.