mirror of
https://github.com/matrix-org/sliding-sync.git
synced 2025-03-10 13:37:11 +00:00
s/rooms/ranges
This commit is contained in:
parent
7e64721f59
commit
6257027a29
@ -409,7 +409,7 @@ const doSyncLoop = async (accessToken, sessionId) => {
|
||||
let reqBody = {
|
||||
lists: activeLists.map((al) => {
|
||||
let l = {
|
||||
rooms: al.activeRanges,
|
||||
ranges: al.activeRanges,
|
||||
filters: al.listFilters,
|
||||
};
|
||||
// if this is the first request on this session, send sticky request data which never changes
|
||||
|
@ -35,7 +35,7 @@ func TestExtensionE2EE(t *testing.T) {
|
||||
})
|
||||
res := v3.mustDoV3Request(t, aliceToken, sync3.Request{
|
||||
Lists: []sync3.RequestList{{
|
||||
Rooms: sync3.SliceRanges{
|
||||
Ranges: sync3.SliceRanges{
|
||||
[2]int64{0, 10}, // doesn't matter
|
||||
},
|
||||
}},
|
||||
@ -62,7 +62,7 @@ func TestExtensionE2EE(t *testing.T) {
|
||||
})
|
||||
res = v3.mustDoV3RequestWithPos(t, aliceToken, res.Pos, sync3.Request{
|
||||
Lists: []sync3.RequestList{{
|
||||
Rooms: sync3.SliceRanges{
|
||||
Ranges: sync3.SliceRanges{
|
||||
[2]int64{0, 10}, // doesn't matter
|
||||
},
|
||||
}},
|
||||
@ -87,7 +87,7 @@ func TestExtensionE2EE(t *testing.T) {
|
||||
v2.waitUntilEmpty(t, alice)
|
||||
res = v3.mustDoV3RequestWithPos(t, aliceToken, res.Pos, sync3.Request{
|
||||
Lists: []sync3.RequestList{{
|
||||
Rooms: sync3.SliceRanges{
|
||||
Ranges: sync3.SliceRanges{
|
||||
[2]int64{0, 10}, // doesn't matter
|
||||
},
|
||||
}},
|
||||
@ -117,7 +117,7 @@ func TestExtensionE2EE(t *testing.T) {
|
||||
lastPos := res.Pos
|
||||
res = v3.mustDoV3RequestWithPos(t, aliceToken, res.Pos, sync3.Request{
|
||||
Lists: []sync3.RequestList{{
|
||||
Rooms: sync3.SliceRanges{
|
||||
Ranges: sync3.SliceRanges{
|
||||
[2]int64{0, 10}, // doesn't matter
|
||||
},
|
||||
}},
|
||||
@ -134,7 +134,7 @@ func TestExtensionE2EE(t *testing.T) {
|
||||
// check that changed|left persist if requesting with the same v3 position
|
||||
res = v3.mustDoV3RequestWithPos(t, aliceToken, lastPos, sync3.Request{
|
||||
Lists: []sync3.RequestList{{
|
||||
Rooms: sync3.SliceRanges{
|
||||
Ranges: sync3.SliceRanges{
|
||||
[2]int64{0, 10}, // doesn't matter
|
||||
},
|
||||
}},
|
||||
@ -161,7 +161,7 @@ func TestExtensionE2EE(t *testing.T) {
|
||||
})
|
||||
res = v3.mustDoV3RequestWithPos(t, aliceToken, res.Pos, sync3.Request{
|
||||
Lists: []sync3.RequestList{{
|
||||
Rooms: sync3.SliceRanges{
|
||||
Ranges: sync3.SliceRanges{
|
||||
[2]int64{0, 10}, // doesn't matter
|
||||
},
|
||||
}},
|
||||
@ -208,7 +208,7 @@ func TestExtensionToDevice(t *testing.T) {
|
||||
// query to-device messages -> get all of them
|
||||
res := v3.mustDoV3Request(t, aliceToken, sync3.Request{
|
||||
Lists: []sync3.RequestList{{
|
||||
Rooms: sync3.SliceRanges{
|
||||
Ranges: sync3.SliceRanges{
|
||||
[2]int64{0, 10}, // doesn't matter
|
||||
},
|
||||
}},
|
||||
@ -224,7 +224,7 @@ func TestExtensionToDevice(t *testing.T) {
|
||||
// repeat request -> get all of them
|
||||
res = v3.mustDoV3Request(t, aliceToken, sync3.Request{
|
||||
Lists: []sync3.RequestList{{
|
||||
Rooms: sync3.SliceRanges{
|
||||
Ranges: sync3.SliceRanges{
|
||||
[2]int64{0, 10}, // doesn't matter
|
||||
},
|
||||
}},
|
||||
@ -240,7 +240,7 @@ func TestExtensionToDevice(t *testing.T) {
|
||||
// update the since token -> don't get messages again
|
||||
res = v3.mustDoV3Request(t, aliceToken, sync3.Request{
|
||||
Lists: []sync3.RequestList{{
|
||||
Rooms: sync3.SliceRanges{
|
||||
Ranges: sync3.SliceRanges{
|
||||
[2]int64{0, 10}, // doesn't matter
|
||||
},
|
||||
}},
|
||||
@ -266,7 +266,7 @@ func TestExtensionToDevice(t *testing.T) {
|
||||
})
|
||||
res = v3.mustDoV3Request(t, aliceToken, sync3.Request{
|
||||
Lists: []sync3.RequestList{{
|
||||
Rooms: sync3.SliceRanges{
|
||||
Ranges: sync3.SliceRanges{
|
||||
[2]int64{0, 10}, // doesn't matter
|
||||
},
|
||||
}},
|
||||
@ -283,7 +283,7 @@ func TestExtensionToDevice(t *testing.T) {
|
||||
// update the since token -> don't get new ones again
|
||||
res = v3.mustDoV3Request(t, aliceToken, sync3.Request{
|
||||
Lists: []sync3.RequestList{{
|
||||
Rooms: sync3.SliceRanges{
|
||||
Ranges: sync3.SliceRanges{
|
||||
[2]int64{0, 10}, // doesn't matter
|
||||
},
|
||||
}},
|
||||
|
@ -56,7 +56,7 @@ func TestFilters(t *testing.T) {
|
||||
encryptedSessionID := "encrypted_session"
|
||||
encryptedRes := v3.mustDoV3Request(t, aliceToken, sync3.Request{
|
||||
Lists: []sync3.RequestList{{
|
||||
Rooms: sync3.SliceRanges{
|
||||
Ranges: sync3.SliceRanges{
|
||||
[2]int64{0, int64(len(allRooms) - 1)}, // all rooms
|
||||
},
|
||||
Filters: &sync3.RequestFilters{
|
||||
@ -77,7 +77,7 @@ func TestFilters(t *testing.T) {
|
||||
unencryptedSessionID := "unencrypted_session"
|
||||
unencryptedRes := v3.mustDoV3Request(t, aliceToken, sync3.Request{
|
||||
Lists: []sync3.RequestList{{
|
||||
Rooms: sync3.SliceRanges{
|
||||
Ranges: sync3.SliceRanges{
|
||||
[2]int64{0, int64(len(allRooms) - 1)}, // all rooms
|
||||
},
|
||||
Filters: &sync3.RequestFilters{
|
||||
@ -120,7 +120,7 @@ func TestFilters(t *testing.T) {
|
||||
// now requesting the encrypted list should include it (added)
|
||||
encryptedRes = v3.mustDoV3RequestWithPos(t, aliceToken, encryptedRes.Pos, sync3.Request{
|
||||
Lists: []sync3.RequestList{{
|
||||
Rooms: sync3.SliceRanges{
|
||||
Ranges: sync3.SliceRanges{
|
||||
[2]int64{0, int64(len(allRooms) - 1)}, // all rooms
|
||||
},
|
||||
// sticky; should remember filters
|
||||
@ -135,7 +135,7 @@ func TestFilters(t *testing.T) {
|
||||
// requesting the encrypted list from scratch returns 2 rooms now
|
||||
encryptedRes = v3.mustDoV3Request(t, aliceToken, sync3.Request{
|
||||
Lists: []sync3.RequestList{{
|
||||
Rooms: sync3.SliceRanges{
|
||||
Ranges: sync3.SliceRanges{
|
||||
[2]int64{0, int64(len(allRooms) - 1)}, // all rooms
|
||||
},
|
||||
Filters: &sync3.RequestFilters{
|
||||
@ -165,7 +165,7 @@ func TestFilters(t *testing.T) {
|
||||
// requesting the unencrypted stream DELETEs the room without a corresponding INSERT
|
||||
unencryptedRes = v3.mustDoV3RequestWithPos(t, aliceToken, unencryptedRes.Pos, sync3.Request{
|
||||
Lists: []sync3.RequestList{{
|
||||
Rooms: sync3.SliceRanges{
|
||||
Ranges: sync3.SliceRanges{
|
||||
[2]int64{0, int64(len(allRooms) - 1)}, // all rooms
|
||||
},
|
||||
// sticky; should remember filters
|
||||
@ -179,7 +179,7 @@ func TestFilters(t *testing.T) {
|
||||
// requesting the unencrypted stream from scratch returns 0 rooms
|
||||
unencryptedRes = v3.mustDoV3Request(t, aliceToken, sync3.Request{
|
||||
Lists: []sync3.RequestList{{
|
||||
Rooms: sync3.SliceRanges{
|
||||
Ranges: sync3.SliceRanges{
|
||||
[2]int64{0, int64(len(allRooms) - 1)}, // all rooms
|
||||
},
|
||||
Filters: &sync3.RequestFilters{
|
||||
|
@ -62,7 +62,7 @@ func TestMultipleLists(t *testing.T) {
|
||||
Lists: []sync3.RequestList{
|
||||
{
|
||||
Sort: []string{sync3.SortByRecency},
|
||||
Rooms: sync3.SliceRanges{
|
||||
Ranges: sync3.SliceRanges{
|
||||
[2]int64{0, 2}, // first 3 rooms
|
||||
},
|
||||
TimelineLimit: 1,
|
||||
@ -72,7 +72,7 @@ func TestMultipleLists(t *testing.T) {
|
||||
},
|
||||
{
|
||||
Sort: []string{sync3.SortByRecency},
|
||||
Rooms: sync3.SliceRanges{
|
||||
Ranges: sync3.SliceRanges{
|
||||
[2]int64{0, 2}, // first 3 rooms
|
||||
},
|
||||
TimelineLimit: 1,
|
||||
@ -107,12 +107,12 @@ func TestMultipleLists(t *testing.T) {
|
||||
res = v3.mustDoV3RequestWithPos(t, aliceToken, res.Pos, sync3.Request{
|
||||
Lists: []sync3.RequestList{
|
||||
{
|
||||
Rooms: sync3.SliceRanges{
|
||||
Ranges: sync3.SliceRanges{
|
||||
[2]int64{0, 2}, // first 3 rooms still
|
||||
},
|
||||
},
|
||||
{
|
||||
Rooms: sync3.SliceRanges{
|
||||
Ranges: sync3.SliceRanges{
|
||||
[2]int64{0, 2}, // first 3 rooms
|
||||
[2]int64{3, 5}, // next 3 rooms
|
||||
},
|
||||
@ -156,12 +156,12 @@ func TestMultipleLists(t *testing.T) {
|
||||
res = v3.mustDoV3RequestWithPos(t, aliceToken, res.Pos, sync3.Request{
|
||||
Lists: []sync3.RequestList{
|
||||
{
|
||||
Rooms: sync3.SliceRanges{
|
||||
Ranges: sync3.SliceRanges{
|
||||
[2]int64{0, 2}, // first 3 rooms still
|
||||
},
|
||||
},
|
||||
{
|
||||
Rooms: sync3.SliceRanges{
|
||||
Ranges: sync3.SliceRanges{
|
||||
[2]int64{0, 2}, // first 3 rooms
|
||||
[2]int64{3, 5}, // next 3 rooms
|
||||
},
|
||||
@ -237,7 +237,7 @@ func TestMultipleListsDMUpdate(t *testing.T) {
|
||||
Lists: []sync3.RequestList{
|
||||
{
|
||||
Sort: []string{sync3.SortByRecency},
|
||||
Rooms: sync3.SliceRanges{
|
||||
Ranges: sync3.SliceRanges{
|
||||
[2]int64{0, 2}, // first 3 rooms
|
||||
},
|
||||
TimelineLimit: 1,
|
||||
@ -247,7 +247,7 @@ func TestMultipleListsDMUpdate(t *testing.T) {
|
||||
},
|
||||
{
|
||||
Sort: []string{sync3.SortByRecency},
|
||||
Rooms: sync3.SliceRanges{
|
||||
Ranges: sync3.SliceRanges{
|
||||
[2]int64{0, 2}, // first 3 rooms
|
||||
},
|
||||
TimelineLimit: 1,
|
||||
@ -300,12 +300,12 @@ func TestMultipleListsDMUpdate(t *testing.T) {
|
||||
res = v3.mustDoV3RequestWithPos(t, aliceToken, res.Pos, sync3.Request{
|
||||
Lists: []sync3.RequestList{
|
||||
{
|
||||
Rooms: sync3.SliceRanges{
|
||||
Ranges: sync3.SliceRanges{
|
||||
[2]int64{0, 2}, // first 3 rooms still
|
||||
},
|
||||
},
|
||||
{
|
||||
Rooms: sync3.SliceRanges{
|
||||
Ranges: sync3.SliceRanges{
|
||||
[2]int64{0, 2}, // first 3 rooms still
|
||||
},
|
||||
},
|
||||
|
@ -56,7 +56,7 @@ func TestNotificationsOnTop(t *testing.T) {
|
||||
// connect and make sure we get nobing, bing
|
||||
syncRequestBody := sync3.Request{
|
||||
Lists: []sync3.RequestList{{
|
||||
Rooms: sync3.SliceRanges{
|
||||
Ranges: sync3.SliceRanges{
|
||||
[2]int64{0, int64(len(allRooms) - 1)}, // all rooms
|
||||
},
|
||||
TimelineLimit: int64(100),
|
||||
@ -133,7 +133,7 @@ func TestNotificationsOnTop(t *testing.T) {
|
||||
v3.restart(t, v2, pqString)
|
||||
res = v3.mustDoV3Request(t, aliceToken, sync3.Request{
|
||||
Lists: []sync3.RequestList{{
|
||||
Rooms: sync3.SliceRanges{
|
||||
Ranges: sync3.SliceRanges{
|
||||
[2]int64{0, int64(len(allRooms) - 1)}, // all rooms
|
||||
},
|
||||
TimelineLimit: int64(100),
|
||||
|
@ -73,7 +73,7 @@ func TestRoomNames(t *testing.T) {
|
||||
// do a sync, make sure room names are sensible
|
||||
res := v3.mustDoV3Request(t, aliceToken, sync3.Request{
|
||||
Lists: []sync3.RequestList{{
|
||||
Rooms: sync3.SliceRanges{
|
||||
Ranges: sync3.SliceRanges{
|
||||
[2]int64{0, int64(len(allRooms) - 1)}, // all rooms
|
||||
},
|
||||
TimelineLimit: int64(100),
|
||||
|
@ -195,7 +195,7 @@ func (s *ConnState) processLiveEvent(connEvent *ConnEvent, responseOperations []
|
||||
s.lists.ForEach(func(index int, list *sync3.FilteredSortableRooms) {
|
||||
// TODO: yuck that the index is here
|
||||
deletedIndex := list.UpdateGlobalRoomMetadata(connEvent.roomMetadata)
|
||||
if deletedIndex >= 0 && s.muxedReq.Lists[index].Rooms.Inside(int64(deletedIndex)) {
|
||||
if deletedIndex >= 0 && s.muxedReq.Lists[index].Ranges.Inside(int64(deletedIndex)) {
|
||||
responseOperations = append(responseOperations, &sync3.ResponseOpSingle{
|
||||
List: index,
|
||||
Operation: sync3.OpDelete,
|
||||
@ -230,7 +230,7 @@ func (s *ConnState) onIncomingListRequest(listIndex int, prevReqList, nextReqLis
|
||||
var prevRange sync3.SliceRanges
|
||||
var prevSort []string
|
||||
if prevReqList != nil {
|
||||
prevRange = prevReqList.Rooms
|
||||
prevRange = prevReqList.Ranges
|
||||
prevSort = prevReqList.Sort
|
||||
}
|
||||
if nextReqList.Sort == nil {
|
||||
@ -241,14 +241,14 @@ func (s *ConnState) onIncomingListRequest(listIndex int, prevReqList, nextReqLis
|
||||
|
||||
var addedRanges, removedRanges sync3.SliceRanges
|
||||
if prevRange != nil {
|
||||
addedRanges, removedRanges, _ = prevRange.Delta(nextReqList.Rooms)
|
||||
addedRanges, removedRanges, _ = prevRange.Delta(nextReqList.Ranges)
|
||||
} else {
|
||||
addedRanges = nextReqList.Rooms
|
||||
addedRanges = nextReqList.Ranges
|
||||
}
|
||||
if !reflect.DeepEqual(prevSort, nextReqList.Sort) {
|
||||
// the sort operations have changed, invalidate everything (if there were previous syncs), re-sort and re-SYNC
|
||||
if prevSort != nil {
|
||||
for _, r := range prevReqList.Rooms {
|
||||
for _, r := range prevReqList.Ranges {
|
||||
responseOperations = append(responseOperations, &sync3.ResponseOpRange{
|
||||
List: listIndex,
|
||||
Operation: sync3.OpInvalidate,
|
||||
@ -259,7 +259,7 @@ func (s *ConnState) onIncomingListRequest(listIndex int, prevReqList, nextReqLis
|
||||
if err := roomList.Sort(nextReqList.Sort); err != nil {
|
||||
logger.Err(err).Int("index", listIndex).Msg("cannot sort list")
|
||||
}
|
||||
addedRanges = nextReqList.Rooms
|
||||
addedRanges = nextReqList.Ranges
|
||||
removedRanges = nil
|
||||
}
|
||||
|
||||
@ -300,7 +300,7 @@ func (s *ConnState) processIncomingUserEvent(roomID string, userEvent *sync3.Use
|
||||
// modify notification counts
|
||||
deletedIndex := list.UpdateUserRoomMetadata(roomID, userEvent, hasCountDecreased)
|
||||
// only notify if we are tracking this index
|
||||
if deletedIndex >= 0 && s.muxedReq.Lists[index].Rooms.Inside(int64(deletedIndex)) {
|
||||
if deletedIndex >= 0 && s.muxedReq.Lists[index].Ranges.Inside(int64(deletedIndex)) {
|
||||
responseOperations = append(responseOperations, &sync3.ResponseOpSingle{
|
||||
List: index,
|
||||
Operation: sync3.OpDelete,
|
||||
@ -385,9 +385,9 @@ func (s *ConnState) resort(listIndex int, reqList *sync3.RequestList, roomList *
|
||||
logger.Info().Msg("moved!")
|
||||
// the toIndex may not be inside a tracked range. If it isn't, we actually need to notify about a
|
||||
// different room
|
||||
if !reqList.Rooms.Inside(int64(toIndex)) {
|
||||
if !reqList.Ranges.Inside(int64(toIndex)) {
|
||||
logger.Info().Msg("room isn't inside tracked range")
|
||||
toIndex = int(reqList.Rooms.UpperClamp(int64(toIndex)))
|
||||
toIndex = int(reqList.Ranges.UpperClamp(int64(toIndex)))
|
||||
count := int(roomList.Len())
|
||||
if toIndex >= count {
|
||||
// no room exists
|
||||
@ -397,7 +397,7 @@ func (s *ConnState) resort(listIndex int, reqList *sync3.RequestList, roomList *
|
||||
return subs, nil
|
||||
}
|
||||
if toIndex == -1 {
|
||||
logger.Warn().Int("from", fromIndex).Int("to", toIndex).Interface("ranges", reqList.Rooms).Msg(
|
||||
logger.Warn().Int("from", fromIndex).Int("to", toIndex).Interface("ranges", reqList.Ranges).Msg(
|
||||
"room moved but not in tracked ranges, ignoring",
|
||||
)
|
||||
return subs, nil
|
||||
@ -416,7 +416,7 @@ func (s *ConnState) resort(listIndex int, reqList *sync3.RequestList, roomList *
|
||||
newEvent = urd.Timeline[len(urd.Timeline)-1]
|
||||
}
|
||||
|
||||
return subs, s.moveRoom(reqList, listIndex, roomID, newEvent, fromIndex, toIndex, reqList.Rooms, isSubscribedToRoom)
|
||||
return subs, s.moveRoom(reqList, listIndex, roomID, newEvent, fromIndex, toIndex, reqList.Ranges, isSubscribedToRoom)
|
||||
}
|
||||
|
||||
func (s *ConnState) updateRoomSubscriptions(timelineLimit int, subs, unsubs []string) map[string]sync3.Room {
|
||||
|
@ -97,7 +97,7 @@ func TestConnStateInitial(t *testing.T) {
|
||||
res, err := cs.OnIncomingRequest(context.Background(), ConnID, &sync3.Request{
|
||||
Lists: []sync3.RequestList{{
|
||||
Sort: []string{sync3.SortByRecency},
|
||||
Rooms: sync3.SliceRanges([][2]int64{
|
||||
Ranges: sync3.SliceRanges([][2]int64{
|
||||
{0, 9},
|
||||
}),
|
||||
}},
|
||||
@ -142,7 +142,7 @@ func TestConnStateInitial(t *testing.T) {
|
||||
res, err = cs.OnIncomingRequest(context.Background(), ConnID, &sync3.Request{
|
||||
Lists: []sync3.RequestList{{
|
||||
Sort: []string{sync3.SortByRecency},
|
||||
Rooms: sync3.SliceRanges([][2]int64{
|
||||
Ranges: sync3.SliceRanges([][2]int64{
|
||||
{0, 9},
|
||||
}),
|
||||
}},
|
||||
@ -175,7 +175,7 @@ func TestConnStateInitial(t *testing.T) {
|
||||
res, err = cs.OnIncomingRequest(context.Background(), ConnID, &sync3.Request{
|
||||
Lists: []sync3.RequestList{{
|
||||
Sort: []string{sync3.SortByRecency},
|
||||
Rooms: sync3.SliceRanges([][2]int64{
|
||||
Ranges: sync3.SliceRanges([][2]int64{
|
||||
{0, 9},
|
||||
}),
|
||||
}},
|
||||
@ -242,7 +242,7 @@ func TestConnStateMultipleRanges(t *testing.T) {
|
||||
res, err := cs.OnIncomingRequest(context.Background(), ConnID, &sync3.Request{
|
||||
Lists: []sync3.RequestList{{
|
||||
Sort: []string{sync3.SortByRecency},
|
||||
Rooms: sync3.SliceRanges([][2]int64{
|
||||
Ranges: sync3.SliceRanges([][2]int64{
|
||||
{0, 2},
|
||||
}),
|
||||
}},
|
||||
@ -274,7 +274,7 @@ func TestConnStateMultipleRanges(t *testing.T) {
|
||||
res, err = cs.OnIncomingRequest(context.Background(), ConnID, &sync3.Request{
|
||||
Lists: []sync3.RequestList{{
|
||||
Sort: []string{sync3.SortByRecency},
|
||||
Rooms: sync3.SliceRanges([][2]int64{
|
||||
Ranges: sync3.SliceRanges([][2]int64{
|
||||
{0, 2}, {4, 6},
|
||||
}),
|
||||
}},
|
||||
@ -317,7 +317,7 @@ func TestConnStateMultipleRanges(t *testing.T) {
|
||||
res, err = cs.OnIncomingRequest(context.Background(), ConnID, &sync3.Request{
|
||||
Lists: []sync3.RequestList{{
|
||||
Sort: []string{sync3.SortByRecency},
|
||||
Rooms: sync3.SliceRanges([][2]int64{
|
||||
Ranges: sync3.SliceRanges([][2]int64{
|
||||
{0, 2}, {4, 6},
|
||||
}),
|
||||
}},
|
||||
@ -357,7 +357,7 @@ func TestConnStateMultipleRanges(t *testing.T) {
|
||||
res, err = cs.OnIncomingRequest(context.Background(), ConnID, &sync3.Request{
|
||||
Lists: []sync3.RequestList{{
|
||||
Sort: []string{sync3.SortByRecency},
|
||||
Rooms: sync3.SliceRanges([][2]int64{
|
||||
Ranges: sync3.SliceRanges([][2]int64{
|
||||
{0, 2}, {4, 6},
|
||||
}),
|
||||
}},
|
||||
@ -424,7 +424,7 @@ func TestBumpToOutsideRange(t *testing.T) {
|
||||
res, err := cs.OnIncomingRequest(context.Background(), ConnID, &sync3.Request{
|
||||
Lists: []sync3.RequestList{{
|
||||
Sort: []string{sync3.SortByRecency},
|
||||
Rooms: sync3.SliceRanges([][2]int64{
|
||||
Ranges: sync3.SliceRanges([][2]int64{
|
||||
{0, 1},
|
||||
}),
|
||||
}},
|
||||
@ -462,7 +462,7 @@ func TestBumpToOutsideRange(t *testing.T) {
|
||||
res, err = cs.OnIncomingRequest(ctx, ConnID, &sync3.Request{
|
||||
Lists: []sync3.RequestList{{
|
||||
Sort: []string{sync3.SortByRecency},
|
||||
Rooms: sync3.SliceRanges([][2]int64{
|
||||
Ranges: sync3.SliceRanges([][2]int64{
|
||||
{0, 1},
|
||||
}),
|
||||
}},
|
||||
@ -538,7 +538,7 @@ func TestConnStateRoomSubscriptions(t *testing.T) {
|
||||
},
|
||||
Lists: []sync3.RequestList{{
|
||||
Sort: []string{sync3.SortByRecency},
|
||||
Rooms: sync3.SliceRanges([][2]int64{
|
||||
Ranges: sync3.SliceRanges([][2]int64{
|
||||
{0, 1},
|
||||
}),
|
||||
}},
|
||||
@ -589,7 +589,7 @@ func TestConnStateRoomSubscriptions(t *testing.T) {
|
||||
res, err = cs.OnIncomingRequest(context.Background(), ConnID, &sync3.Request{
|
||||
Lists: []sync3.RequestList{{
|
||||
Sort: []string{sync3.SortByRecency},
|
||||
Rooms: sync3.SliceRanges([][2]int64{
|
||||
Ranges: sync3.SliceRanges([][2]int64{
|
||||
{0, 1},
|
||||
}),
|
||||
}},
|
||||
@ -620,7 +620,7 @@ func TestConnStateRoomSubscriptions(t *testing.T) {
|
||||
UnsubscribeRooms: []string{roomD.RoomID},
|
||||
Lists: []sync3.RequestList{{
|
||||
Sort: []string{sync3.SortByRecency},
|
||||
Rooms: sync3.SliceRanges([][2]int64{
|
||||
Ranges: sync3.SliceRanges([][2]int64{
|
||||
{0, 1},
|
||||
}),
|
||||
}},
|
||||
|
@ -31,7 +31,7 @@ type Request struct {
|
||||
}
|
||||
|
||||
type RequestList struct {
|
||||
Rooms SliceRanges `json:"rooms"`
|
||||
Ranges SliceRanges `json:"ranges"`
|
||||
Sort []string `json:"sort"`
|
||||
RequiredState [][2]string `json:"required_state"`
|
||||
TimelineLimit int64 `json:"timeline_limit"`
|
||||
@ -83,9 +83,9 @@ func (r *Request) ApplyDelta(nextReq *Request) (result *Request, subs, unsubs []
|
||||
existingList = &r.Lists[i]
|
||||
}
|
||||
nextList := nextReq.Lists[i]
|
||||
rooms := nextList.Rooms
|
||||
rooms := nextList.Ranges
|
||||
if rooms == nil {
|
||||
rooms = existingList.Rooms
|
||||
rooms = existingList.Ranges
|
||||
}
|
||||
sort := nextList.Sort
|
||||
if sort == nil {
|
||||
@ -104,7 +104,7 @@ func (r *Request) ApplyDelta(nextReq *Request) (result *Request, subs, unsubs []
|
||||
filters = existingList.Filters
|
||||
}
|
||||
lists[i] = RequestList{
|
||||
Rooms: rooms,
|
||||
Ranges: rooms,
|
||||
Sort: sort,
|
||||
RequiredState: reqState,
|
||||
TimelineLimit: timelineLimit,
|
||||
|
@ -162,7 +162,7 @@ func TestTimelinesLiveStream(t *testing.T) {
|
||||
// first request => rooms 19,18,17,16
|
||||
res := v3.mustDoV3Request(t, aliceToken, sync3.Request{
|
||||
Lists: []sync3.RequestList{{
|
||||
Rooms: sync3.SliceRanges{
|
||||
Ranges: sync3.SliceRanges{
|
||||
[2]int64{0, int64(len(wantRooms) - 1)}, // first N rooms
|
||||
},
|
||||
TimelineLimit: int64(numTimelineEventsPerRoom),
|
||||
@ -192,7 +192,7 @@ func TestTimelinesLiveStream(t *testing.T) {
|
||||
// next request, DELETE 3; INSERT 0 7;
|
||||
res = v3.mustDoV3RequestWithPos(t, aliceToken, res.Pos, sync3.Request{
|
||||
Lists: []sync3.RequestList{{
|
||||
Rooms: sync3.SliceRanges{
|
||||
Ranges: sync3.SliceRanges{
|
||||
[2]int64{0, int64(len(wantRooms) - 1)}, // first N rooms
|
||||
},
|
||||
// sticky remember the timeline_limit
|
||||
@ -212,7 +212,7 @@ func TestTimelinesLiveStream(t *testing.T) {
|
||||
// next request, UPDATE 0 7;
|
||||
res = v3.mustDoV3RequestWithPos(t, aliceToken, res.Pos, sync3.Request{
|
||||
Lists: []sync3.RequestList{{
|
||||
Rooms: sync3.SliceRanges{
|
||||
Ranges: sync3.SliceRanges{
|
||||
[2]int64{0, int64(len(wantRooms) - 1)}, // first N rooms
|
||||
},
|
||||
}},
|
||||
@ -226,7 +226,7 @@ func TestTimelinesLiveStream(t *testing.T) {
|
||||
// next request, DELETE 2; INSERT 0 18;
|
||||
res = v3.mustDoV3RequestWithPos(t, aliceToken, res.Pos, sync3.Request{
|
||||
Lists: []sync3.RequestList{{
|
||||
Rooms: sync3.SliceRanges{
|
||||
Ranges: sync3.SliceRanges{
|
||||
[2]int64{0, int64(len(wantRooms) - 1)}, // first N rooms
|
||||
},
|
||||
}},
|
||||
@ -262,7 +262,7 @@ func TestInitialFlag(t *testing.T) {
|
||||
})
|
||||
res := v3.mustDoV3Request(t, aliceToken, sync3.Request{
|
||||
Lists: []sync3.RequestList{{
|
||||
Rooms: sync3.SliceRanges{
|
||||
Ranges: sync3.SliceRanges{
|
||||
[2]int64{0, 10},
|
||||
},
|
||||
TimelineLimit: 10,
|
||||
@ -276,7 +276,7 @@ func TestInitialFlag(t *testing.T) {
|
||||
})
|
||||
res = v3.mustDoV3RequestWithPos(t, aliceToken, res.Pos, sync3.Request{
|
||||
Lists: []sync3.RequestList{{
|
||||
Rooms: sync3.SliceRanges{
|
||||
Ranges: sync3.SliceRanges{
|
||||
[2]int64{0, 10},
|
||||
},
|
||||
}},
|
||||
@ -295,7 +295,7 @@ func testTimelineLoadInitialEvents(v3 *testV3Server, token string, count int, wa
|
||||
return func(t *testing.T) {
|
||||
res := v3.mustDoV3Request(t, token, sync3.Request{
|
||||
Lists: []sync3.RequestList{{
|
||||
Rooms: sync3.SliceRanges{
|
||||
Ranges: sync3.SliceRanges{
|
||||
[2]int64{0, int64(len(wantRooms) - 1)}, // first N rooms
|
||||
},
|
||||
TimelineLimit: int64(numTimelineEventsPerRoom),
|
||||
|
Loading…
x
Reference in New Issue
Block a user