Don't limit "state" (#2849)

This is apparently some incorrect behaviour that we built as a result of
a spec bug (matrix-org/matrix-spec#1314) where we were applying a filter
to the `"state"` section of the `/sync` response incorrectly. The client
then has no way to know that the state was limited.

This PR removes the state limiting, which probably also helps #2842.
This commit is contained in:
Neil Alexander 2022-11-02 09:34:19 +00:00 committed by GitHub
parent 8a1904ffe5
commit 3db9e98456
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 15 additions and 21 deletions

View file

@ -277,7 +277,8 @@ func (s *currentRoomStateStatements) SelectCurrentState(
},
stateFilter.Senders, stateFilter.NotSenders,
stateFilter.Types, stateFilter.NotTypes,
excludeEventIDs, stateFilter.ContainsURL, stateFilter.Limit, FilterOrderNone,
excludeEventIDs, stateFilter.ContainsURL, 0,
FilterOrderNone,
)
if err != nil {
return nil, fmt.Errorf("s.prepareWithFilters: %w", err)

View file

@ -84,8 +84,10 @@ func prepareWithFilters(
case FilterOrderDesc:
query += " ORDER BY id DESC"
}
query += fmt.Sprintf(" LIMIT $%d", offset+1)
params = append(params, limit)
if limit > 0 {
query += fmt.Sprintf(" LIMIT $%d", offset+1)
params = append(params, limit)
}
var stmt *sql.Stmt
var err error

View file

@ -200,7 +200,7 @@ func (s *outputRoomEventsStatements) SelectStateInRange(
s.db, txn, stmtSQL, inputParams,
stateFilter.Senders, stateFilter.NotSenders,
stateFilter.Types, stateFilter.NotTypes,
nil, stateFilter.ContainsURL, stateFilter.Limit, FilterOrderAsc,
nil, stateFilter.ContainsURL, 0, FilterOrderAsc,
)
} else {
stmt, params, err = prepareWithFilters(