@@ -619,7 +619,7 @@ func (s *SyncDeviceSuite) TestPairPendingContactRequest() {
619
619
type contactRequestAction func (messenger * protocol.Messenger , contactRequestID string ) (* protocol.MessengerResponse , error )
620
620
type notificationValidateFunc func (r * protocol.ActivityCenterPaginationResponse )
621
621
622
- func (s * SyncDeviceSuite ) testPairContactRequest (requestAction contactRequestAction , validateFunc notificationValidateFunc ) {
622
+ func (s * SyncDeviceSuite ) testPairContactRequest (requestAction contactRequestAction , validateFunc notificationValidateFunc , validateFuncPaired notificationValidateFunc ) {
623
623
bobBackend , _ := s .createUser ("bob" )
624
624
defer func () {
625
625
s .Require ().NoError (bobBackend .Logout ())
@@ -648,7 +648,7 @@ func (s *SyncDeviceSuite) testPairContactRequest(requestAction contactRequestAct
648
648
}()
649
649
s .pairAccounts (alice1Backend , alice1TmpDir , alice2Backend , alice2TmpDir )
650
650
651
- internalNotificationValidateFunc := func (m * protocol.Messenger ) {
651
+ internalNotificationValidateFunc := func (m * protocol.Messenger , isPairedDevice bool ) {
652
652
acRequest := protocol.ActivityCenterNotificationsRequest {
653
653
ActivityTypes : []protocol.ActivityCenterType {
654
654
protocol .ActivityCenterNotificationTypeContactRequest ,
@@ -658,35 +658,51 @@ func (s *SyncDeviceSuite) testPairContactRequest(requestAction contactRequestAct
658
658
}
659
659
r , err := m .ActivityCenterNotifications (acRequest )
660
660
s .Require ().NoError (err )
661
- validateFunc (r )
661
+ if isPairedDevice {
662
+ validateFuncPaired (r )
663
+ } else {
664
+ validateFunc (r )
665
+ }
662
666
}
663
667
664
- internalNotificationValidateFunc (alice1Backend .Messenger ())
665
- internalNotificationValidateFunc (alice2Backend .Messenger ())
668
+ internalNotificationValidateFunc (alice1Backend .Messenger (), false )
669
+ internalNotificationValidateFunc (alice2Backend .Messenger (), true )
666
670
}
667
671
668
672
func (s * SyncDeviceSuite ) TestPairDeclineContactRequest () {
669
673
declineContactRequest := func (messenger * protocol.Messenger , contactRequestID string ) (* protocol.MessengerResponse , error ) {
670
674
return messenger .DeclineContactRequest (context .Background (), & requests.DeclineContactRequest {ID : types .Hex2Bytes (contactRequestID )})
671
675
}
672
- s . testPairContactRequest ( declineContactRequest , func (r * protocol.ActivityCenterPaginationResponse ) {
676
+ validateFunc := func (r * protocol.ActivityCenterPaginationResponse ) {
673
677
s .Require ().Len (r .Notifications , 1 )
674
678
s .Require ().False (r .Notifications [0 ].Accepted )
675
679
s .Require ().True (r .Notifications [0 ].Dismissed )
676
680
s .Require ().True (r .Notifications [0 ].Read )
677
- })
681
+ }
682
+ s .testPairContactRequest (
683
+ declineContactRequest ,
684
+ validateFunc ,
685
+ // The paired device will get a notification because the request will not be fulfilled (not mutual)
686
+ validateFunc ,
687
+ )
678
688
}
679
689
680
690
func (s * SyncDeviceSuite ) TestPairAcceptContactRequest () {
681
691
acceptContactRequest := func (messenger * protocol.Messenger , contactRequestID string ) (* protocol.MessengerResponse , error ) {
682
692
return messenger .AcceptContactRequest (context .Background (), & requests.AcceptContactRequest {ID : types .Hex2Bytes (contactRequestID )})
683
693
}
684
- s .testPairContactRequest (acceptContactRequest , func (r * protocol.ActivityCenterPaginationResponse ) {
685
- s .Require ().Len (r .Notifications , 1 )
686
- s .Require ().True (r .Notifications [0 ].Accepted )
687
- s .Require ().False (r .Notifications [0 ].Dismissed )
688
- s .Require ().True (r .Notifications [0 ].Read )
689
- })
694
+ s .testPairContactRequest (
695
+ acceptContactRequest ,
696
+ func (r * protocol.ActivityCenterPaginationResponse ) {
697
+ s .Require ().Len (r .Notifications , 1 )
698
+ s .Require ().True (r .Notifications [0 ].Accepted )
699
+ s .Require ().False (r .Notifications [0 ].Dismissed )
700
+ s .Require ().True (r .Notifications [0 ].Read )
701
+ },
702
+ // The paired device doesn't need a notification because it will receive the fully mutual contact
703
+ func (r * protocol.ActivityCenterPaginationResponse ) {
704
+ s .Require ().Len (r .Notifications , 0 )
705
+ })
690
706
}
691
707
692
708
type testTimeSource struct {}
0 commit comments