@@ -300,14 +300,15 @@ func TestMsgEvents(t *testing.T) {
300
300
301
301
makeMsgTask := func (org * testdata.Org , channel * testdata.Channel , contact * testdata.Contact , text string ) * queue.Task {
302
302
return & queue.Task {Type : handler .MsgEventType , OrgID : int (org .ID ), Task : jsonx .MustMarshal (& handler.MsgEvent {
303
- ContactID : contact .ID ,
304
- OrgID : org .ID ,
305
- ChannelID : channel .ID ,
306
- MsgID : dbMsg .ID (),
307
- MsgUUID : dbMsg .UUID (),
308
- URN : contact .URN ,
309
- URNID : contact .URNID ,
310
- Text : text ,
303
+ ContactID : contact .ID ,
304
+ OrgID : org .ID ,
305
+ ChannelUUID : channel .UUID ,
306
+ ChannelType : channel .Type ,
307
+ MsgID : dbMsg .ID (),
308
+ MsgUUID : dbMsg .UUID (),
309
+ URN : contact .URN ,
310
+ URNID : contact .URNID ,
311
+ Text : text ,
311
312
})}
312
313
}
313
314
@@ -587,47 +588,47 @@ func TestTimedEvents(t *testing.T) {
587
588
Contact * testdata.Contact
588
589
Message string
589
590
Response string
590
- ChannelID models. ChannelID
591
- OrgID models. OrgID
591
+ Channel * testdata. Channel
592
+ Org * testdata. Org
592
593
}{
593
594
// 0: start the flow
594
- {handler .MsgEventType , testdata .Cathy , "start" , "What is your favorite color?" , testdata .TwitterChannel . ID , testdata .Org1 . ID },
595
+ {handler .MsgEventType , testdata .Cathy , "start" , "What is your favorite color?" , testdata .TwitterChannel , testdata .Org1 },
595
596
596
597
// 1: this expiration does nothing because the times don't match
597
- {handler .ExpirationEventType , testdata .Cathy , "bad" , "" , testdata .TwitterChannel . ID , testdata .Org1 . ID },
598
+ {handler .ExpirationEventType , testdata .Cathy , "bad" , "" , testdata .TwitterChannel , testdata .Org1 },
598
599
599
600
// 2: this checks that the flow wasn't expired
600
- {handler .MsgEventType , testdata .Cathy , "red" , "Good choice, I like Red too! What is your favorite beer?" , testdata .TwitterChannel . ID , testdata .Org1 . ID },
601
+ {handler .MsgEventType , testdata .Cathy , "red" , "Good choice, I like Red too! What is your favorite beer?" , testdata .TwitterChannel , testdata .Org1 },
601
602
602
603
// 3: this expiration will actually take
603
- {handler .ExpirationEventType , testdata .Cathy , "good" , "" , testdata .TwitterChannel . ID , testdata .Org1 . ID },
604
+ {handler .ExpirationEventType , testdata .Cathy , "good" , "" , testdata .TwitterChannel , testdata .Org1 },
604
605
605
606
// 4: we won't get a response as we will be out of the flow
606
- {handler .MsgEventType , testdata .Cathy , "mutzig" , "" , testdata .TwitterChannel . ID , testdata .Org1 . ID },
607
+ {handler .MsgEventType , testdata .Cathy , "mutzig" , "" , testdata .TwitterChannel , testdata .Org1 },
607
608
608
609
// 5: start the parent expiration flow
609
- {handler .MsgEventType , testdata .Cathy , "parent" , "Child" , testdata .TwitterChannel . ID , testdata .Org1 . ID },
610
+ {handler .MsgEventType , testdata .Cathy , "parent" , "Child" , testdata .TwitterChannel , testdata .Org1 },
610
611
611
612
// 6: respond, should bring us out
612
- {handler .MsgEventType , testdata .Cathy , "hi" , "Completed" , testdata .TwitterChannel . ID , testdata .Org1 . ID },
613
+ {handler .MsgEventType , testdata .Cathy , "hi" , "Completed" , testdata .TwitterChannel , testdata .Org1 },
613
614
614
615
// 7: expiring our child should be a no op
615
- {handler .ExpirationEventType , testdata .Cathy , "child" , "" , testdata .TwitterChannel . ID , testdata .Org1 . ID },
616
+ {handler .ExpirationEventType , testdata .Cathy , "child" , "" , testdata .TwitterChannel , testdata .Org1 },
616
617
617
618
// 8: respond one last time, should be done
618
- {handler .MsgEventType , testdata .Cathy , "done" , "Ended" , testdata .TwitterChannel . ID , testdata .Org1 . ID },
619
+ {handler .MsgEventType , testdata .Cathy , "done" , "Ended" , testdata .TwitterChannel , testdata .Org1 },
619
620
620
621
// 9: start our favorite flow again
621
- {handler .MsgEventType , testdata .Cathy , "start" , "What is your favorite color?" , testdata .TwitterChannel . ID , testdata .Org1 . ID },
622
+ {handler .MsgEventType , testdata .Cathy , "start" , "What is your favorite color?" , testdata .TwitterChannel , testdata .Org1 },
622
623
623
624
// 10: timeout on the color question
624
- {handler .TimeoutEventType , testdata .Cathy , "" , "Sorry you can't participate right now, I'll try again later." , testdata .TwitterChannel . ID , testdata .Org1 . ID },
625
+ {handler .TimeoutEventType , testdata .Cathy , "" , "Sorry you can't participate right now, I'll try again later." , testdata .TwitterChannel , testdata .Org1 },
625
626
626
627
// 11: start the pick a number flow
627
- {handler .MsgEventType , testdata .Cathy , "pick" , "Pick a number between 1-10." , testdata .TwitterChannel . ID , testdata .Org1 . ID },
628
+ {handler .MsgEventType , testdata .Cathy , "pick" , "Pick a number between 1-10." , testdata .TwitterChannel , testdata .Org1 },
628
629
629
630
// 12: try to resume with timeout even tho flow doesn't have one set
630
- {handler .TimeoutEventType , testdata .Cathy , "" , "" , testdata .TwitterChannel . ID , testdata .Org1 . ID },
631
+ {handler .TimeoutEventType , testdata .Cathy , "" , "" , testdata .TwitterChannel , testdata .Org1 },
631
632
}
632
633
633
634
last := time .Now ()
@@ -642,16 +643,17 @@ func TestTimedEvents(t *testing.T) {
642
643
if tc .EventType == handler .MsgEventType {
643
644
task = & queue.Task {
644
645
Type : tc .EventType ,
645
- OrgID : int (tc .OrgID ),
646
+ OrgID : int (tc .Org . ID ),
646
647
Task : jsonx .MustMarshal (& handler.MsgEvent {
647
- ContactID : tc .Contact .ID ,
648
- OrgID : tc .OrgID ,
649
- ChannelID : tc .ChannelID ,
650
- MsgID : flows .MsgID (1 ),
651
- MsgUUID : flows .MsgUUID (uuids .New ()),
652
- URN : tc .Contact .URN ,
653
- URNID : tc .Contact .URNID ,
654
- Text : tc .Message ,
648
+ ContactID : tc .Contact .ID ,
649
+ OrgID : tc .Org .ID ,
650
+ ChannelUUID : tc .Channel .UUID ,
651
+ ChannelType : tc .Channel .Type ,
652
+ MsgID : flows .MsgID (1 ),
653
+ MsgUUID : flows .MsgUUID (uuids .New ()),
654
+ URN : tc .Contact .URN ,
655
+ URNID : tc .Contact .URNID ,
656
+ Text : tc .Message ,
655
657
}),
656
658
}
657
659
} else if tc .EventType == handler .ExpirationEventType {
@@ -666,15 +668,15 @@ func TestTimedEvents(t *testing.T) {
666
668
expiration = time .Now ().Add (time .Hour * 24 )
667
669
}
668
670
669
- task = handler .NewExpirationTask (tc .OrgID , tc .Contact .ID , sessionID , expiration )
671
+ task = handler .NewExpirationTask (tc .Org . ID , tc .Contact .ID , sessionID , expiration )
670
672
671
673
} else if tc .EventType == handler .TimeoutEventType {
672
674
timeoutOn := time .Now ().Round (time .Millisecond ) // so that there's no difference between this and what we read from the db
673
675
674
676
// usually courier will set timeout_on after sending the last message
675
677
db .MustExec (`UPDATE flows_flowsession SET timeout_on = $2 WHERE id = $1` , sessionID , timeoutOn )
676
678
677
- task = handler .NewTimeoutTask (tc .OrgID , tc .Contact .ID , sessionID , timeoutOn )
679
+ task = handler .NewTimeoutTask (tc .Org . ID , tc .Contact .ID , sessionID , timeoutOn )
678
680
}
679
681
680
682
err := handler .QueueHandleTask (rc , tc .Contact .ID , task )
0 commit comments