diff --git a/handlers/bandwidth/handler.go b/handlers/bandwidth/handler.go index 3b7e16814..57eed2c9b 100644 --- a/handlers/bandwidth/handler.go +++ b/handlers/bandwidth/handler.go @@ -23,8 +23,10 @@ var ( ) const ( - configAccountID = "account_id" - configApplicationID = "application_id" + configAccountID = "account_id" + configMsgApplicationID = "messaging_application_id" + + oldApplicationID = "application_id" ) func init() { @@ -177,7 +179,10 @@ func (h *handler) Send(ctx context.Context, msg courier.MsgOut, res *courier.Sen username := msg.Channel().StringConfigForKey(courier.ConfigUsername, "") password := msg.Channel().StringConfigForKey(courier.ConfigPassword, "") accountID := msg.Channel().StringConfigForKey(configAccountID, "") - applicationID := msg.Channel().StringConfigForKey(configApplicationID, "") + applicationID := msg.Channel().StringConfigForKey(configMsgApplicationID, "") + if applicationID == "" { + applicationID = msg.Channel().StringConfigForKey(oldApplicationID, "") + } if username == "" || password == "" || accountID == "" || applicationID == "" { return courier.ErrChannelConfig diff --git a/handlers/bandwidth/handler_test.go b/handlers/bandwidth/handler_test.go index 8de22d04e..64731e6c2 100644 --- a/handlers/bandwidth/handler_test.go +++ b/handlers/bandwidth/handler_test.go @@ -238,7 +238,7 @@ func TestIncoming(t *testing.T) { chs := []courier.Channel{ test.NewMockChannel("8eb23e93-5ecb-45ba-b726-3b064e0c56ab", "BW", "2020", "US", []string{urns.Phone.Prefix}, - map[string]any{courier.ConfigUsername: "user1", courier.ConfigPassword: "pass1", configAccountID: "accound-id", configApplicationID: "application-id"}, + map[string]any{courier.ConfigUsername: "user1", courier.ConfigPassword: "pass1", configAccountID: "accound-id", configMsgApplicationID: "application-id"}, ), } @@ -357,7 +357,7 @@ var outgoingCases = []OutgoingTestCase{ func TestOutgoing(t *testing.T) { ch := test.NewMockChannel("8eb23e93-5ecb-45ba-b726-3b064e0c56ab", "BW", "2020", "US", []string{urns.Phone.Prefix}, - map[string]any{courier.ConfigUsername: "user1", courier.ConfigPassword: "pass1", configAccountID: "accound-id", configApplicationID: "application-id"}, + map[string]any{courier.ConfigUsername: "user1", courier.ConfigPassword: "pass1", configAccountID: "accound-id", configMsgApplicationID: "application-id"}, ) RunOutgoingTestCases(t, ch, newHandler(), outgoingCases, []string{httpx.BasicAuth("user1", "pass1")}, nil) @@ -367,7 +367,7 @@ func TestBuildAttachmentRequest(t *testing.T) { mb := test.NewMockBackend() ch := test.NewMockChannel("8eb23e93-5ecb-45ba-b726-3b064e0c56ab", "BW", "2020", "US", []string{urns.Phone.Prefix}, - map[string]any{courier.ConfigUsername: "user1", courier.ConfigPassword: "pass1", configAccountID: "accound-id", configApplicationID: "application-id"}, + map[string]any{courier.ConfigUsername: "user1", courier.ConfigPassword: "pass1", configAccountID: "accound-id", configMsgApplicationID: "application-id"}, ) bwHandler := &handler{NewBaseHandler(courier.ChannelType("BW"), "Bandwidth")}