Skip to content

Commit

Permalink
[MM-57489] Check for StatusCode when receiving responses from the pus…
Browse files Browse the repository at this point in the history
…h proxy (mattermost#27392)
  • Loading branch information
devinbinnie authored Jun 19, 2024
1 parent 3a890e1 commit f41e8ad
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions server/channels/app/notification_push.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit f41e8ad

Please sign in to comment.