From f41e8ad756e5ad6758bae101cc5e87bbc570eea1 Mon Sep 17 00:00:00 2001 From: Devin Binnie <52460000+devinbinnie@users.noreply.github.com> Date: Wed, 19 Jun 2024 09:18:26 -0400 Subject: [PATCH] [MM-57489] Check for StatusCode when receiving responses from the push proxy (#27392) --- server/channels/app/notification_push.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/server/channels/app/notification_push.go b/server/channels/app/notification_push.go index 7acc161852..98ed6403db 100644 --- a/server/channels/app/notification_push.go +++ b/server/channels/app/notification_push.go @@ -490,6 +490,10 @@ func (a *App) rawSendToPushProxy(msg *model.PushNotification) (model.PushRespons } defer resp.Body.Close() + if resp.StatusCode != http.StatusOK { + return nil, fmt.Errorf("response returned error code: %d", resp.StatusCode) + } + var pushResponse model.PushResponse if err := json.NewDecoder(resp.Body).Decode(&pushResponse); err != nil { return nil, fmt.Errorf("failed to decode from JSON: %w", err) @@ -562,6 +566,10 @@ func (a *App) SendAckToPushProxy(ack *model.PushNotificationAck) error { } defer resp.Body.Close() + if resp.StatusCode != http.StatusOK { + return fmt.Errorf("response returned error code: %d", resp.StatusCode) + } + // Reading the body to completion. _, err = io.Copy(io.Discard, resp.Body) return err