Skip to content

Commit

Permalink
Merge pull request rapidpro#298 from nyaruka/telesom-fix
Browse files Browse the repository at this point in the history
TS sends mobile instead of from parameter
  • Loading branch information
nicpottier authored May 11, 2020
2 parents fee2583 + 5998edc commit 583e053
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions handlers/telesom/telesom.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func (h *handler) Initialize(s courier.Server) error {
}

type moForm struct {
From string `name:"from" validate:"required"`
Mobile string `name:"mobile" validate:"required"`
Message string `name:"msg" validate:"required"`
}

Expand All @@ -52,7 +52,7 @@ func (h *handler) receiveMessage(ctx context.Context, channel courier.Channel, w
return nil, handlers.WriteAndLogRequestError(ctx, h, channel, w, r, err)
}
// create our URN
urn, err := handlers.StrictTelForCountry(form.From, channel.Country())
urn, err := handlers.StrictTelForCountry(form.Mobile, channel.Country())
if err != nil {
return nil, handlers.WriteAndLogRequestError(ctx, h, channel, w, r, err)
}
Expand Down
16 changes: 8 additions & 8 deletions handlers/telesom/telesom_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import (
)

var (
receiveValidMessage = "/c/ts/8eb23e93-5ecb-45ba-b726-3b064e0c56ab/receive/?from=%2B2349067554729&msg=Join"
receiveValidMessage = "/c/ts/8eb23e93-5ecb-45ba-b726-3b064e0c56ab/receive/?mobile=%2B2349067554729&msg=Join"
receiveNoParams = "/c/ts/8eb23e93-5ecb-45ba-b726-3b064e0c56ab/receive/"
invalidURN = "/c/ts/8eb23e93-5ecb-45ba-b726-3b064e0c56ab/receive/?from=MTN&msg=Join"
invalidURN = "/c/ts/8eb23e93-5ecb-45ba-b726-3b064e0c56ab/receive/?mobile=MTN&msg=Join"
receiveNoSender = "/c/ts/8eb23e93-5ecb-45ba-b726-3b064e0c56ab/receive/?msg=Join"
)

Expand All @@ -25,14 +25,14 @@ var handleTestCases = []ChannelHandleTestCase{
{Label: "Receive Valid Message", URL: receiveValidMessage, Data: "", Status: 200, Response: "Accepted",
Text: Sp("Join"), URN: Sp("tel:+2349067554729")},
{Label: "Invalid URN", URL: invalidURN, Data: "", Status: 400, Response: "phone number supplied is not a number"},
{Label: "Receive No Params", URL: receiveNoParams, Data: "", Status: 400, Response: "field 'from' required"},
{Label: "Receive No Sender", URL: receiveNoSender, Data: "", Status: 400, Response: "field 'from' required"},
{Label: "Receive No Params", URL: receiveNoParams, Data: "", Status: 400, Response: "field 'mobile' required"},
{Label: "Receive No Sender", URL: receiveNoSender, Data: "", Status: 400, Response: "field 'mobile' required"},

{Label: "Receive Valid Message", URL: receiveNoParams, Data: "from=%2B2349067554729&msg=Join", Status: 200, Response: "Accepted",
{Label: "Receive Valid Message", URL: receiveNoParams, Data: "mobile=%2B2349067554729&msg=Join", Status: 200, Response: "Accepted",
Text: Sp("Join"), URN: Sp("tel:+2349067554729")},
{Label: "Invalid URN", URL: receiveNoParams, Data: "from=MTN&msg=Join", Status: 400, Response: "phone number supplied is not a number"},
{Label: "Receive No Params", URL: receiveNoParams, Data: "empty", Status: 400, Response: "field 'from' required"},
{Label: "Receive No Sender", URL: receiveNoParams, Data: "msg=Join", Status: 400, Response: "field 'from' required"},
{Label: "Invalid URN", URL: receiveNoParams, Data: "mobile=MTN&msg=Join", Status: 400, Response: "phone number supplied is not a number"},
{Label: "Receive No Params", URL: receiveNoParams, Data: "empty", Status: 400, Response: "field 'mobile' required"},
{Label: "Receive No Sender", URL: receiveNoParams, Data: "msg=Join", Status: 400, Response: "field 'mobile' required"},
}

func TestHandler(t *testing.T) {
Expand Down

0 comments on commit 583e053

Please sign in to comment.