mirror of
https://github.com/matrix-org/sliding-sync.git
synced 2025-03-10 13:37:11 +00:00
bugfix: ensure we send back device list updates at the correct time
Otherwise we can cause lost device list updates if the client resets the connection (as the device list update won't be in any in-memory cache).
This commit is contained in:
parent
5816c60e33
commit
c5b0afb2be
@ -70,6 +70,9 @@ func (t *DeviceDataTable) Select(userID, deviceID string, swap bool) (result *in
|
||||
if !swap {
|
||||
return nil // don't swap
|
||||
}
|
||||
// the caller will only look at sent, so make sure what is new is now in sent
|
||||
result.DeviceLists.Sent = result.DeviceLists.New
|
||||
|
||||
// swap over the fields
|
||||
writeBack := *result
|
||||
writeBack.DeviceLists.Sent = result.DeviceLists.New
|
||||
|
@ -193,6 +193,48 @@ func TestExtensionE2EE(t *testing.T) {
|
||||
if time.Since(start) >= (500 * time.Millisecond) {
|
||||
t.Fatalf("sync request did not return immediately with OTK counts")
|
||||
}
|
||||
|
||||
// check that if we lose a device list update and restart from nothing, we see the same update
|
||||
v2.queueResponse(alice, sync2.SyncResponse{
|
||||
DeviceLists: struct {
|
||||
Changed []string `json:"changed,omitempty"`
|
||||
Left []string `json:"left,omitempty"`
|
||||
}{
|
||||
Changed: wantChanged,
|
||||
Left: wantLeft,
|
||||
},
|
||||
})
|
||||
v2.waitUntilEmpty(t, alice)
|
||||
res = v3.mustDoV3RequestWithPos(t, aliceToken, res.Pos, sync3.Request{
|
||||
Lists: map[string]sync3.RequestList{"a": {
|
||||
Ranges: sync3.SliceRanges{
|
||||
[2]int64{0, 10}, // doesn't matter
|
||||
},
|
||||
}},
|
||||
// enable the E2EE extension
|
||||
Extensions: extensions.Request{
|
||||
E2EE: &extensions.E2EERequest{
|
||||
Core: extensions.Core{Enabled: &boolTrue},
|
||||
},
|
||||
},
|
||||
})
|
||||
m.MatchResponse(t, res, m.MatchDeviceLists(wantChanged, wantLeft))
|
||||
// we actually lost this update: start again and we should see it.
|
||||
res = v3.mustDoV3Request(t, aliceToken, sync3.Request{
|
||||
Lists: map[string]sync3.RequestList{"a": {
|
||||
Ranges: sync3.SliceRanges{
|
||||
[2]int64{0, 10}, // doesn't matter
|
||||
},
|
||||
}},
|
||||
// enable the E2EE extension
|
||||
Extensions: extensions.Request{
|
||||
E2EE: &extensions.E2EERequest{
|
||||
Core: extensions.Core{Enabled: &boolTrue},
|
||||
},
|
||||
},
|
||||
})
|
||||
m.MatchResponse(t, res, m.MatchDeviceLists(wantChanged, wantLeft))
|
||||
|
||||
}
|
||||
|
||||
// Checks that to-device messages are passed from v2 to v3
|
||||
|
Loading…
x
Reference in New Issue
Block a user