Skip to content

Commit

Permalink
bug fixes from running in a QA env against https://whatsapp.praekelt.…
Browse files Browse the repository at this point in the history
  • Loading branch information
smn committed Sep 19, 2018
1 parent 46f24a1 commit 4ff7375
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type URNDescriber interface {

// MediaDownloadRequestBuilder is the interface handlers which can allow a custom way to download attachment media for messages should satisfy
type MediaDownloadRequestBuilder interface {
BuildDownloadMediaRequest(context.Context, Channel, string) (*http.Request, error)
BuildDownloadMediaRequest(context.Context, Backend, Channel, string) (*http.Request, error)
}

// RegisterHandler adds a new handler for a channel type, this is called by individual handlers when they are initialized
Expand Down
4 changes: 2 additions & 2 deletions handlers/whatsapp/whatsapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,8 @@ func (h *handler) SendMsg(ctx context.Context, msg courier.Msg) (courier.MsgStat

// upload it to WhatsApp in exchange for a media id
waReq, _ := http.NewRequest(http.MethodPost, mediaURL, bytes.NewReader(s3rr.Body))
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", token))
req.Header.Set("Content-Type", mimeType)
waReq.Header.Set("Authorization", fmt.Sprintf("Bearer %s", token))
waReq.Header.Set("Content-Type", mimeType)
wArr, err := utils.MakeHTTPRequest(waReq)
if err != nil {
log := courier.NewChannelLogFromRR("Error uploading Media for sending", msg.Channel(), msg.ID(), wArr).WithError("Message Send Error", err)
Expand Down
10 changes: 4 additions & 6 deletions utils/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,11 @@ func newRRFromResponse(method string, requestTrace string, r *http.Response) (*R
}
rr.Response = string(response)

if isText {
bodyBytes, err := ioutil.ReadAll(r.Body)
if err != nil {
return &rr, err
}
rr.Body = bodyBytes
bodyBytes, err := ioutil.ReadAll(r.Body)
if err != nil {
return &rr, err
}
rr.Body = bodyBytes

// return an error if we got a non-200 status
if err == nil && rr.Status != RRStatusSuccess {
Expand Down

0 comments on commit 4ff7375

Please sign in to comment.