Tweaks to pagination

This commit is contained in:
Neil Alexander 2022-10-12 11:35:23 +01:00
parent 2a374fc272
commit 566bfae939
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
4 changed files with 9 additions and 8 deletions

View file

@ -45,6 +45,7 @@ func Setup(
lazyLoadCache caching.LazyLoadCache,
fts *fulltext.Search,
) {
v1mux := csMux.PathPrefix("/v1/").Subrouter()
v3mux := csMux.PathPrefix("/{apiversion:(?:r0|v3)}/").Subrouter()
// TODO: Add AS support for all handlers below.
@ -110,7 +111,7 @@ func Setup(
}),
).Methods(http.MethodGet, http.MethodOptions)
v3mux.Handle("/rooms/{roomId}/relations/{eventId}",
v1mux.Handle("/rooms/{roomId}/relations/{eventId}",
httputil.MakeAuthAPI(gomatrixserverlib.Join, userAPI, func(req *http.Request, device *userapi.Device) util.JSONResponse {
vars, err := httputil.URLDecodeMapValues(mux.Vars(req))
if err != nil {
@ -124,7 +125,7 @@ func Setup(
}),
).Methods(http.MethodGet, http.MethodOptions)
v3mux.Handle("/rooms/{roomId}/relations/{eventId}/{relType}",
v1mux.Handle("/rooms/{roomId}/relations/{eventId}/{relType}",
httputil.MakeAuthAPI(gomatrixserverlib.Join, userAPI, func(req *http.Request, device *userapi.Device) util.JSONResponse {
vars, err := httputil.URLDecodeMapValues(mux.Vars(req))
if err != nil {
@ -138,7 +139,7 @@ func Setup(
}),
).Methods(http.MethodGet, http.MethodOptions)
v3mux.Handle("/rooms/{roomId}/relations/{eventId}/{relType}/{eventType}",
v1mux.Handle("/rooms/{roomId}/relations/{eventId}/{relType}/{eventType}",
httputil.MakeAuthAPI(gomatrixserverlib.Join, userAPI, func(req *http.Request, device *userapi.Device) util.JSONResponse {
vars, err := httputil.URLDecodeMapValues(mux.Vars(req))
if err != nil {

View file

@ -50,12 +50,12 @@ const deleteRelationSQL = "" +
const selectRelationsInRangeSQL = "" +
"SELECT id, room_id, child_event_id, rel_type FROM syncapi_relations" +
" WHERE room_id = $1 AND event_id = $2 AND id >= $3 AND id <= $4" +
" WHERE room_id = $1 AND event_id = $2 AND id > $3 AND id <= $4" +
" ORDER BY id DESC LIMIT $5"
const selectRelationsByTypeInRangeSQL = "" +
"SELECT id, room_id, child_event_id, rel_type FROM syncapi_relations" +
" WHERE room_id = $1 AND event_id = $2 AND rel_type = $3 AND id >= $4 AND id <= $5" +
" WHERE room_id = $1 AND event_id = $2 AND rel_type = $3 AND id > $4 AND id <= $5" +
" ORDER BY id DESC LIMIT $6"
const selectMaxRelationIDSQL = "" +

View file

@ -636,7 +636,7 @@ func (d *DatabaseTransaction) RelationsFor(ctx context.Context, roomID, eventID,
// If there were no entries returned, there were no relations, so stop at this point.
if len(entries) == 0 {
return nil, "", "", nil
return clientEvents, "", "", nil
}
// Otherwise, let's try and work out what sensible prev_batch and next_batch values

View file

@ -48,12 +48,12 @@ const deleteRelationSQL = "" +
const selectRelationsInRangeSQL = "" +
"SELECT id, room_id, child_event_id, rel_type FROM syncapi_relations" +
" WHERE room_id = $1 AND event_id = $2 AND id >= $3 AND id <= $4" +
" WHERE room_id = $1 AND event_id = $2 AND id > $3 AND id <= $4" +
" ORDER BY id DESC LIMIT $5"
const selectRelationsByTypeInRangeSQL = "" +
"SELECT id, room_id, child_event_id, rel_type FROM syncapi_relations" +
" WHERE room_id = $1 AND event_id = $2 AND rel_type = $3 AND id >= $4 AND id <= $5" +
" WHERE room_id = $1 AND event_id = $2 AND rel_type = $3 AND id > $4 AND id <= $5" +
" ORDER BY id DESC LIMIT $6"
const selectMaxRelationIDSQL = "" +