Skip to content

Commit 351be51

Browse files
authored
Merge pull request #854 from nyaruka/bw-app-id
Rename config for BW messaging application ID
2 parents fb98f0b + 4603c46 commit 351be51

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

handlers/bandwidth/handler.go

+8-3
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ var (
2323
)
2424

2525
const (
26-
configAccountID = "account_id"
27-
configApplicationID = "application_id"
26+
configAccountID = "account_id"
27+
configMsgApplicationID = "messaging_application_id"
28+
29+
oldApplicationID = "application_id"
2830
)
2931

3032
func init() {
@@ -177,7 +179,10 @@ func (h *handler) Send(ctx context.Context, msg courier.MsgOut, res *courier.Sen
177179
username := msg.Channel().StringConfigForKey(courier.ConfigUsername, "")
178180
password := msg.Channel().StringConfigForKey(courier.ConfigPassword, "")
179181
accountID := msg.Channel().StringConfigForKey(configAccountID, "")
180-
applicationID := msg.Channel().StringConfigForKey(configApplicationID, "")
182+
applicationID := msg.Channel().StringConfigForKey(configMsgApplicationID, "")
183+
if applicationID == "" {
184+
applicationID = msg.Channel().StringConfigForKey(oldApplicationID, "")
185+
}
181186

182187
if username == "" || password == "" || accountID == "" || applicationID == "" {
183188
return courier.ErrChannelConfig

handlers/bandwidth/handler_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ func TestIncoming(t *testing.T) {
238238
chs := []courier.Channel{
239239
test.NewMockChannel("8eb23e93-5ecb-45ba-b726-3b064e0c56ab", "BW", "2020", "US",
240240
[]string{urns.Phone.Prefix},
241-
map[string]any{courier.ConfigUsername: "user1", courier.ConfigPassword: "pass1", configAccountID: "accound-id", configApplicationID: "application-id"},
241+
map[string]any{courier.ConfigUsername: "user1", courier.ConfigPassword: "pass1", configAccountID: "accound-id", configMsgApplicationID: "application-id"},
242242
),
243243
}
244244

@@ -357,7 +357,7 @@ var outgoingCases = []OutgoingTestCase{
357357
func TestOutgoing(t *testing.T) {
358358
ch := test.NewMockChannel("8eb23e93-5ecb-45ba-b726-3b064e0c56ab", "BW", "2020", "US",
359359
[]string{urns.Phone.Prefix},
360-
map[string]any{courier.ConfigUsername: "user1", courier.ConfigPassword: "pass1", configAccountID: "accound-id", configApplicationID: "application-id"},
360+
map[string]any{courier.ConfigUsername: "user1", courier.ConfigPassword: "pass1", configAccountID: "accound-id", configMsgApplicationID: "application-id"},
361361
)
362362

363363
RunOutgoingTestCases(t, ch, newHandler(), outgoingCases, []string{httpx.BasicAuth("user1", "pass1")}, nil)
@@ -367,7 +367,7 @@ func TestBuildAttachmentRequest(t *testing.T) {
367367
mb := test.NewMockBackend()
368368
ch := test.NewMockChannel("8eb23e93-5ecb-45ba-b726-3b064e0c56ab", "BW", "2020", "US",
369369
[]string{urns.Phone.Prefix},
370-
map[string]any{courier.ConfigUsername: "user1", courier.ConfigPassword: "pass1", configAccountID: "accound-id", configApplicationID: "application-id"},
370+
map[string]any{courier.ConfigUsername: "user1", courier.ConfigPassword: "pass1", configAccountID: "accound-id", configMsgApplicationID: "application-id"},
371371
)
372372

373373
bwHandler := &handler{NewBaseHandler(courier.ChannelType("BW"), "Bandwidth")}

0 commit comments

Comments
 (0)