From cbdf0c4b36517d4c083775efd2788ad801f4e928 Mon Sep 17 00:00:00 2001 From: Gabriel Vasile Date: Mon, 22 Jul 2024 14:10:54 +0900 Subject: [PATCH] check webhook http response code --- ms_teams.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ms_teams.go b/ms_teams.go index 0724d8e..42540ff 100644 --- a/ms_teams.go +++ b/ms_teams.go @@ -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 }