diff options
author | Thibaut CHARLES <cromfr@gmail.com> | 2019-08-07 12:12:09 +0200 |
---|---|---|
committer | Andrew Morgan <1342360+anoadragon453@users.noreply.github.com> | 2019-08-07 11:12:09 +0100 |
commit | 76e4ebaf78a698eb775ccb358fb5c253084747b9 (patch) | |
tree | 8619e6518bed53412f78612e81b122f0ef806499 /syncapi/routing | |
parent | 94ea325c93d03362795ce85c49008797d37d36dd (diff) |
State events filtering database api (#438)
This PR adds a gomatrixserverlib.Filter parameter to functions handling the syncapi_current_room_state table. It does not implement any filtering logic inside the syncapi IncrementalSync/CompleteSync functions, just the APIs for future use.
Default filters are provided as placeholders in IncrementalSync/CompleteSync, so behaviour should be unchanged (except the default 20 event limit)
SQL table will be changed. You can upgrade an existing database using:
```
ALTER TABLE syncapi_current_room_state ADD COLUMN IF NOT EXISTS sender text;
UPDATE syncapi_current_room_state SET sender=(event_json::json->>'sender');
ALTER TABLE syncapi_current_room_state ALTER COLUMN sender SET NOT NULL;
ALTER TABLE syncapi_current_room_state ADD COLUMN IF NOT EXISTS contains_url bool;
UPDATE syncapi_current_room_state SET contains_url=(event_json::json->>'content')::json->>'url' IS NOT NULL;
ALTER TABLE syncapi_current_room_state ALTER COLUMN contains_url SET NOT NULL;
```
Note: This depends on #436 (and includes all its commits). I'm not sure if Github will remove the duplicated commits once #436 is merged.
Diffstat (limited to 'syncapi/routing')
-rw-r--r-- | syncapi/routing/state.go | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/syncapi/routing/state.go b/syncapi/routing/state.go index 5571a052..87a93d19 100644 --- a/syncapi/routing/state.go +++ b/syncapi/routing/state.go @@ -44,7 +44,10 @@ func OnIncomingStateRequest(req *http.Request, db *storage.SyncServerDatasource, // TODO(#287): Auth request and handle the case where the user has left (where // we should return the state at the poin they left) - stateEvents, err := db.GetStateEventsForRoom(req.Context(), roomID) + stateFilterPart := gomatrixserverlib.DefaultFilterPart() + // TODO: stateFilterPart should not limit the number of state events (or only limits abusive number of events) + + stateEvents, err := db.GetStateEventsForRoom(req.Context(), roomID, &stateFilterPart) if err != nil { return httputil.LogThenError(req, err) } |