Skip to content

Commit

Permalink
Fix sending bandwidth MMS without text
Browse files Browse the repository at this point in the history
  • Loading branch information
norkans7 committed Jan 7, 2024
1 parent d19befe commit 2ac235a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
5 changes: 5 additions & 0 deletions handlers/bandwidth/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,12 @@ func (h *handler) Send(ctx context.Context, msg courier.MsgOut, clog *courier.Ch
msgParts := make([]string, 0)
if msg.Text() != "" {
msgParts = handlers.SplitMsgByChannel(msg.Channel(), msg.Text(), maxMsgLength)
} else {
if len(msg.Attachments()) > 0 {
msgParts = append(msgParts, "")
}
}

for i, part := range msgParts {
payload := &mtPayload{}
payload.ApplicationID = applicationID
Expand Down
21 changes: 21 additions & 0 deletions handlers/bandwidth/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,27 @@ var defaultSendTestCases = []OutgoingTestCase{
ExpectedExternalID: "55555",
SendPrep: setSendURL,
},
{
Label: "Send Attachment no text",
MsgText: "",
MsgURN: "tel:+12067791234",
MsgAttachments: []string{"image/jpeg:https://foo.bar/image.jpg"},
MockResponseBody: `{"id": "55555"}`,
MockResponseStatus: 200,
ExpectedRequests: []ExpectedRequest{
{
Headers: map[string]string{
"Content-Type": "application/json",
"Accept": "application/json",
"Authorization": "Basic dXNlcjE6cGFzczE=",
},
Body: `{"applicationId":"application-id","to":["+12067791234"],"from":"2020","text":"","media":["https://foo.bar/image.jpg"]}`,
},
},
ExpectedMsgStatus: "W",
ExpectedExternalID: "55555",
SendPrep: setSendURL,
},
{
Label: "No External ID",
MsgText: "No External ID",
Expand Down

0 comments on commit 2ac235a

Please sign in to comment.