From 304c03ec3932c78f944b606c135aa1b759f3b8a4 Mon Sep 17 00:00:00 2001 From: Rafael Soares Date: Wed, 1 Feb 2023 17:10:53 -0300 Subject: [PATCH] fix wenichats send media --- services/tickets/wenichats/web.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/services/tickets/wenichats/web.go b/services/tickets/wenichats/web.go index 684d2851b..c6ff6ab69 100644 --- a/services/tickets/wenichats/web.go +++ b/services/tickets/wenichats/web.go @@ -1,6 +1,7 @@ package wenichats import ( + "bytes" "context" "encoding/json" "io" @@ -91,14 +92,14 @@ func handleEventCallback(ctx context.Context, rt *runtime.Runtime, r *http.Reque maxBodyBytes = mb100 } bodyReader := io.LimitReader(file.Body, int64(maxBodyBytes)+1) - _, err = io.ReadAll(bodyReader) + bodyBytes, err := io.ReadAll(bodyReader) if err != nil { return err, http.StatusBadRequest, nil } if bodyReader.(*io.LimitedReader).N <= 0 { return errors.Wrapf(err, "unable to send media type %s because response body exceeds %d bytes limit", file.ContentType, maxBodyBytes), http.StatusBadRequest, nil } - + file.Body = io.NopCloser(bytes.NewReader(bodyBytes)) _, err = tickets.SendReply(ctx, rt, ticket, "", []*tickets.File{file}) if err != nil { return errors.Wrapf(err, "error on send ticket reply with media '%s'", m.URL), http.StatusInternalServerError, nil