From d925f3fa8f764acd6b8d4ef1ee88667c9166dab3 Mon Sep 17 00:00:00 2001 From: Lev Petrushchak Date: Fri, 5 Aug 2022 16:32:32 +0300 Subject: [PATCH] Added backward compatible roomName --- cmd/handlers.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cmd/handlers.go b/cmd/handlers.go index 3b8aed0..ae90127 100644 --- a/cmd/handlers.go +++ b/cmd/handlers.go @@ -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)