Skip to content

Commit

Permalink
check webhook http response code
Browse files Browse the repository at this point in the history
  • Loading branch information
gabriel-vasile committed Jul 22, 2024
1 parent b848999 commit cbdf0c4
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions ms_teams.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,12 @@ func (card *MsTeam) Send() (err error) {

defer resp.Body.Close()

respBody, err := ioutil.ReadAll(resp.Body)
if err != nil {
return err
}
if string(respBody) != "1" {
return errors.New("cannot push to MSTeams")
if resp.StatusCode != http.StatusAccepted {
respBody, err := io.ReadAll(io.LimitReader(resp.Body, 1024*1024))
if err != nil {
return err
}
return fmt.Errorf("unexpected response from webhook: %s", string(respBody))
}
return
}

0 comments on commit cbdf0c4

Please sign in to comment.