mirror of
https://github.com/matrix-org/sliding-sync.git
synced 2025-03-10 13:37:11 +00:00
Use LastMessageTimestamp in the case there are no bumpEventTypes defined
This commit is contained in:
parent
fbd68d8c71
commit
2758b62c86
@ -626,7 +626,7 @@ func (s *ConnState) getInitialRoomData(ctx context.Context, roomSub sync3.RoomSu
|
||||
if roomListsMeta == nil {
|
||||
break
|
||||
}
|
||||
|
||||
|
||||
evMeta := roomListsMeta.LatestEventsByType[t]
|
||||
if evMeta.Timestamp > maxTs {
|
||||
maxTs = evMeta.Timestamp
|
||||
@ -639,6 +639,12 @@ func (s *ConnState) getInitialRoomData(ctx context.Context, roomSub sync3.RoomSu
|
||||
if maxTs == 0 || maxTs < roomListsMeta.JoinTiming.Timestamp {
|
||||
if roomListsMeta != nil {
|
||||
maxTs = roomListsMeta.JoinTiming.Timestamp
|
||||
// If no bumpEventTypes are specified, use the
|
||||
// LastMessageTimestamp so clients are still able
|
||||
// to correctly sort on it.
|
||||
if len(bumpEventTypes) == 0 {
|
||||
maxTs = roomListsMeta.LastMessageTimestamp
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -163,4 +163,18 @@ func TestTimestamp(t *testing.T) {
|
||||
if gotTs != expectedTs {
|
||||
t.Fatalf("Charlie should see the timestamp they joined, but didn't: %d, expected %d", gotTs, expectedTs)
|
||||
}
|
||||
|
||||
// Initial sync without bump types should see the most recent timestamp
|
||||
resAlice = alice.SlidingSync(t, sync3.Request{
|
||||
RoomSubscriptions: map[string]sync3.RoomSubscription{
|
||||
roomID: {
|
||||
TimelineLimit: 10,
|
||||
},
|
||||
},
|
||||
})
|
||||
// expected TS stays the same, so the join of Charlie
|
||||
gotTs = resAlice.Rooms[roomID].Timestamp
|
||||
if gotTs != expectedTs {
|
||||
t.Fatalf("Alice should see the timestamp of Charlie joining, but didn't: %d, expected %d", gotTs, expectedTs)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user