mirror of
https://github.com/matrix-org/sliding-sync.git
synced 2025-03-10 13:37:11 +00:00
If no required_state is sent; don't pull out all room state
This commit is contained in:
parent
f6de179c0a
commit
fbc49564c9
@ -62,6 +62,13 @@ func (rsm *RequiredStateMap) Include(evType, stateKey string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (rsm *RequiredStateMap) Empty() bool {
|
||||
return !rsm.allState && !rsm.lazyLoading &&
|
||||
len(rsm.eventTypeToStateKeys) == 0 &&
|
||||
len(rsm.stateKeysForWildcardEventType) == 0 &&
|
||||
len(rsm.eventTypesWithWildcardStateKeys) == 0
|
||||
}
|
||||
|
||||
// work out what to ask the storage layer: if we have wildcard event types we need to pull all
|
||||
// room state and cannot only pull out certain event types. If we have wildcard state keys we
|
||||
// need to use an empty list for state keys.
|
||||
|
@ -140,6 +140,9 @@ func (c *GlobalCache) LoadRoomState(ctx context.Context, roomIDs []string, loadP
|
||||
if c.store == nil {
|
||||
return nil
|
||||
}
|
||||
if requiredStateMap.Empty() {
|
||||
return nil
|
||||
}
|
||||
resultMap := make(map[string][]json.RawMessage, len(roomIDs))
|
||||
roomIDToStateEvents, err := c.store.RoomStateAfterEventPosition(ctx, roomIDs, loadPosition, requiredStateMap.QueryStateMap())
|
||||
if err != nil {
|
||||
|
@ -405,7 +405,9 @@ func (s *ConnState) getInitialRoomData(ctx context.Context, roomSub sync3.RoomSu
|
||||
}
|
||||
rsm := roomSub.RequiredStateMap(s.userID)
|
||||
roomIDToState := s.globalCache.LoadRoomState(ctx, roomIDs, s.loadPosition, rsm, roomToUsersInTimeline)
|
||||
|
||||
if roomIDToState == nil { // e.g no required_state
|
||||
roomIDToState = make(map[string][]json.RawMessage)
|
||||
}
|
||||
for _, roomID := range roomIDs {
|
||||
userRoomData, ok := roomIDToUserRoomData[roomID]
|
||||
if !ok {
|
||||
@ -423,6 +425,9 @@ func (s *ConnState) getInitialRoomData(ctx context.Context, roomSub sync3.RoomSu
|
||||
var requiredState []json.RawMessage
|
||||
if !userRoomData.IsInvite {
|
||||
requiredState = roomIDToState[roomID]
|
||||
if requiredState == nil {
|
||||
requiredState = make([]json.RawMessage, 0)
|
||||
}
|
||||
}
|
||||
prevBatch, _ := userRoomData.PrevBatch()
|
||||
rooms[roomID] = sync3.Room{
|
||||
|
Loading…
x
Reference in New Issue
Block a user