Skip to content

Commit

Permalink
Update to latest goflow which has some changes to wait expirations
Browse files Browse the repository at this point in the history
  • Loading branch information
rowanseymour committed Jan 24, 2025
1 parent 0b91c88 commit 76fa01b
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 21 deletions.
16 changes: 8 additions & 8 deletions core/models/flows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestLoadFlows(t *testing.T) {
name string
expectedType models.FlowType
expectedEngineType flows.FlowType
expectedExpire int
expectedExpire time.Duration
expectedIVRRetry *time.Duration
}

Expand All @@ -46,7 +46,7 @@ func TestLoadFlows(t *testing.T) {
"Favorites",
models.FlowTypeMessaging,
flows.FlowTypeMessaging,
720,
720 * time.Minute,
&sixtyMinutes, // uses default
},
{
Expand All @@ -56,8 +56,8 @@ func TestLoadFlows(t *testing.T) {
"Pick a Number",
models.FlowTypeMessaging,
flows.FlowTypeMessaging,
5, // clamped to minimum
&sixtyMinutes, // uses default
5 * time.Minute, // clamped to minimum
&sixtyMinutes, // uses default
},
{
testdata.Org1,
Expand All @@ -66,8 +66,8 @@ func TestLoadFlows(t *testing.T) {
"Send All",
models.FlowTypeMessaging,
flows.FlowTypeMessaging,
43200, // clamped to maximum
&sixtyMinutes, // uses default
43200 * time.Minute, // clamped to maximum
&sixtyMinutes, // uses default
},
{
testdata.Org1,
Expand All @@ -76,7 +76,7 @@ func TestLoadFlows(t *testing.T) {
"IVR Flow",
models.FlowTypeVoice,
flows.FlowTypeVoice,
5,
5 * time.Minute,
&thirtyMinutes, // uses explicit
},
}
Expand All @@ -97,7 +97,7 @@ func TestLoadFlows(t *testing.T) {
assert.Equal(t, tc.uuid, flow.UUID(), "engine UUID mismatch for %s", desc)
assert.Equal(t, tc.name, flow.Name(), "engine name mismatch for %s", desc)
assert.Equal(t, tc.expectedEngineType, flow.Type(), "engine type mismatch for %s", desc)
assert.Equal(t, tc.expectedExpire, flow.ExpireAfterMinutes(), "engine expire mismatch for %s", desc)
assert.Equal(t, tc.expectedExpire, flow.ExpireAfter(), "engine expire mismatch for %s", desc)

}

Expand Down
4 changes: 2 additions & 2 deletions core/models/sessions.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ func (s *Session) updateWait(evts []flows.Event) {
run, _ := s.findStep(e.StepUUID())

s.s.WaitStartedOn = &now
s.s.WaitExpiresOn = typed.ExpiresOn
s.s.WaitExpiresOn = &typed.ExpiresOn
s.s.WaitResumeOnExpire = canResume(run)

if typed.TimeoutSeconds != nil {
Expand All @@ -236,7 +236,7 @@ func (s *Session) updateWait(evts []flows.Event) {
run, _ := s.findStep(e.StepUUID())

s.s.WaitStartedOn = &now
s.s.WaitExpiresOn = typed.ExpiresOn
s.s.WaitExpiresOn = &typed.ExpiresOn
s.s.WaitResumeOnExpire = canResume(run)
}
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ require (
github.com/lib/pq v1.10.9
github.com/nyaruka/ezconf v0.3.0
github.com/nyaruka/gocommon v1.60.5
github.com/nyaruka/goflow v0.227.0
github.com/nyaruka/goflow v0.228.0
github.com/nyaruka/null/v3 v3.0.0
github.com/nyaruka/redisx v0.9.0
github.com/nyaruka/rp-indexer/v9 v9.3.4
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ github.com/nyaruka/ezconf v0.3.0 h1:kGvJqVN8AHowb4HdaHAviJ0Z3yI5Pyekp1WqibFEaGk=
github.com/nyaruka/ezconf v0.3.0/go.mod h1:89GUW6EPRNLIxT7lC4LWnjWTgZeQwRoX7lBmc8ralAU=
github.com/nyaruka/gocommon v1.60.5 h1:V10rosGzVArRspilfbi65TyHBZzjLQbwmaBeicr2Drw=
github.com/nyaruka/gocommon v1.60.5/go.mod h1:kFJuOq8COneV7ssfK6xgCMJ8gP8fQifLQnNXBnE4YL0=
github.com/nyaruka/goflow v0.227.0 h1:FeybAXbcuXV/hwBCPUVAiQwhVAxsWEzKwqSriQ9rnZM=
github.com/nyaruka/goflow v0.227.0/go.mod h1:spXtSWgS7dusHIfUFCvJGjSMc7d4FX9Abl6S7tg49ks=
github.com/nyaruka/goflow v0.228.0 h1:GiPJBJcFS8WxF+tIVET/GiAzzW4QJ9Wdxs2fwR2aXd4=
github.com/nyaruka/goflow v0.228.0/go.mod h1:spXtSWgS7dusHIfUFCvJGjSMc7d4FX9Abl6S7tg49ks=
github.com/nyaruka/null/v2 v2.0.3 h1:rdmMRQyVzrOF3Jff/gpU/7BDR9mQX0lcLl4yImsA3kw=
github.com/nyaruka/null/v2 v2.0.3/go.mod h1:OCVeCkCXwrg5/qE6RU0c1oUVZBy+ZDrT+xYg1XSaIWA=
github.com/nyaruka/null/v3 v3.0.0 h1:JvOiNuKmRBFHxzZFt4sWii+ewmMkCQ1vO7X0clTNn6E=
Expand Down
8 changes: 4 additions & 4 deletions services/ivr/twiml/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,30 +80,30 @@ func TestResponseForSprint(t *testing.T) {
// ivr msg followed by wait for digits
events: []flows.Event{
events.NewIVRCreated(flows.NewIVRMsgOut(urn, channelRef, "enter a number", "", "")),
events.NewMsgWait(nil, nil, hints.NewFixedDigitsHint(1)),
events.NewMsgWait(nil, expiresOn, hints.NewFixedDigitsHint(1)),
},
expected: `<Response><Gather numDigits="1" timeout="30" action="http://temba.io/resume?session=1&amp;wait_type=gather"><Say language="en-US">enter a number</Say></Gather><Redirect>http://temba.io/resume?session=1&amp;wait_type=gather&amp;timeout=true</Redirect></Response>`,
},
{
// ivr msg followed by wait for terminated digits
events: []flows.Event{
events.NewIVRCreated(flows.NewIVRMsgOut(urn, channelRef, "enter a number, then press #", "", "")),
events.NewMsgWait(nil, nil, hints.NewTerminatedDigitsHint("#")),
events.NewMsgWait(nil, expiresOn, hints.NewTerminatedDigitsHint("#")),
},
expected: `<Response><Gather finishOnKey="#" timeout="30" action="http://temba.io/resume?session=1&amp;wait_type=gather"><Say language="en-US">enter a number, then press #</Say></Gather><Redirect>http://temba.io/resume?session=1&amp;wait_type=gather&amp;timeout=true</Redirect></Response>`,
},
{
// ivr msg followed by wait for recording
events: []flows.Event{
events.NewIVRCreated(flows.NewIVRMsgOut(urn, channelRef, "say something", "", "")),
events.NewMsgWait(nil, nil, hints.NewAudioHint()),
events.NewMsgWait(nil, expiresOn, hints.NewAudioHint()),
},
expected: `<Response><Say language="en-US">say something</Say><Record action="http://temba.io/resume?session=1&amp;wait_type=record" maxLength="600"></Record><Redirect>http://temba.io/resume?session=1&amp;wait_type=record&amp;empty=true</Redirect></Response>`,
},
{
// dial wait
events: []flows.Event{
events.NewDialWait(urns.URN(`tel:+1234567890`), 60, 7200, &expiresOn),
events.NewDialWait(urns.URN(`tel:+1234567890`), 60, 7200, expiresOn),
},
expected: `<Response><Dial action="http://temba.io/resume?session=1&amp;wait_type=dial" timeout="60" timeLimit="7200">+1234567890</Dial></Response>`,
},
Expand Down
8 changes: 4 additions & 4 deletions services/ivr/vonage/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,27 +101,27 @@ func TestResponseForSprint(t *testing.T) {
{
[]flows.Event{
events.NewIVRCreated(flows.NewIVRMsgOut(urn, channelRef, "enter a number", "", "")),
events.NewMsgWait(nil, nil, hints.NewFixedDigitsHint(1)),
events.NewMsgWait(nil, expiresOn, hints.NewFixedDigitsHint(1)),
},
`[{"action":"talk","text":"enter a number","bargeIn":true},{"action":"input","maxDigits":1,"submitOnHash":true,"timeOut":30,"eventUrl":["http://temba.io/resume?session=1\u0026wait_type=gather\u0026sig=4Yil1wUntXd%2F7AQx%2Bt0rkwihx%2Fg%3D"],"eventMethod":"POST"}]`,
},
{
[]flows.Event{
events.NewIVRCreated(flows.NewIVRMsgOut(urn, channelRef, "enter a number, then press #", "", "")),
events.NewMsgWait(nil, nil, hints.NewTerminatedDigitsHint("#")),
events.NewMsgWait(nil, expiresOn, hints.NewTerminatedDigitsHint("#")),
},
`[{"action":"talk","text":"enter a number, then press #","bargeIn":true},{"action":"input","maxDigits":20,"submitOnHash":true,"timeOut":30,"eventUrl":["http://temba.io/resume?session=1\u0026wait_type=gather\u0026sig=4Yil1wUntXd%2F7AQx%2Bt0rkwihx%2Fg%3D"],"eventMethod":"POST"}]`,
},
{
[]flows.Event{
events.NewIVRCreated(flows.NewIVRMsgOut(urn, channelRef, "say something", "", "")),
events.NewMsgWait(nil, nil, hints.NewAudioHint()),
events.NewMsgWait(nil, expiresOn, hints.NewAudioHint()),
},
`[{"action":"talk","text":"say something"},{"action":"record","endOnKey":"#","timeOut":600,"endOnSilence":5,"eventUrl":["http://temba.io/resume?session=1\u0026wait_type=recording_url\u0026recording_uuid=f3ede2d6-becc-4ea3-ae5e-88526a9f4a57\u0026sig=1M351E3KlL5x2ZHZKCdWaQYP98g%3D"],"eventMethod":"POST"},{"action":"input","submitOnHash":true,"timeOut":1,"eventUrl":["http://temba.io/resume?session=1\u0026wait_type=record\u0026recording_uuid=f3ede2d6-becc-4ea3-ae5e-88526a9f4a57\u0026sig=deq3V%2BVVIHFMwboNhIxSpnVjAUQ%3D"],"eventMethod":"POST"}]`,
},
{
[]flows.Event{
events.NewDialWait(urns.URN(`tel:+1234567890`), 60, 7200, &expiresOn),
events.NewDialWait(urns.URN(`tel:+1234567890`), 60, 7200, expiresOn),
},
`[{"action":"conversation","name":"8bcb9ef2-d4a6-4314-b68d-6d299761ea9e"}]`,
},
Expand Down

0 comments on commit 76fa01b

Please sign in to comment.