mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-16 18:43:10 -06:00
Tweaks to pagination
This commit is contained in:
parent
2a374fc272
commit
566bfae939
|
|
@ -45,6 +45,7 @@ func Setup(
|
||||||
lazyLoadCache caching.LazyLoadCache,
|
lazyLoadCache caching.LazyLoadCache,
|
||||||
fts *fulltext.Search,
|
fts *fulltext.Search,
|
||||||
) {
|
) {
|
||||||
|
v1mux := csMux.PathPrefix("/v1/").Subrouter()
|
||||||
v3mux := csMux.PathPrefix("/{apiversion:(?:r0|v3)}/").Subrouter()
|
v3mux := csMux.PathPrefix("/{apiversion:(?:r0|v3)}/").Subrouter()
|
||||||
|
|
||||||
// TODO: Add AS support for all handlers below.
|
// TODO: Add AS support for all handlers below.
|
||||||
|
|
@ -110,7 +111,7 @@ func Setup(
|
||||||
}),
|
}),
|
||||||
).Methods(http.MethodGet, http.MethodOptions)
|
).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 {
|
httputil.MakeAuthAPI(gomatrixserverlib.Join, userAPI, func(req *http.Request, device *userapi.Device) util.JSONResponse {
|
||||||
vars, err := httputil.URLDecodeMapValues(mux.Vars(req))
|
vars, err := httputil.URLDecodeMapValues(mux.Vars(req))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -124,7 +125,7 @@ func Setup(
|
||||||
}),
|
}),
|
||||||
).Methods(http.MethodGet, http.MethodOptions)
|
).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 {
|
httputil.MakeAuthAPI(gomatrixserverlib.Join, userAPI, func(req *http.Request, device *userapi.Device) util.JSONResponse {
|
||||||
vars, err := httputil.URLDecodeMapValues(mux.Vars(req))
|
vars, err := httputil.URLDecodeMapValues(mux.Vars(req))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -138,7 +139,7 @@ func Setup(
|
||||||
}),
|
}),
|
||||||
).Methods(http.MethodGet, http.MethodOptions)
|
).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 {
|
httputil.MakeAuthAPI(gomatrixserverlib.Join, userAPI, func(req *http.Request, device *userapi.Device) util.JSONResponse {
|
||||||
vars, err := httputil.URLDecodeMapValues(mux.Vars(req))
|
vars, err := httputil.URLDecodeMapValues(mux.Vars(req))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -50,12 +50,12 @@ const deleteRelationSQL = "" +
|
||||||
|
|
||||||
const selectRelationsInRangeSQL = "" +
|
const selectRelationsInRangeSQL = "" +
|
||||||
"SELECT id, room_id, child_event_id, rel_type FROM syncapi_relations" +
|
"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"
|
" ORDER BY id DESC LIMIT $5"
|
||||||
|
|
||||||
const selectRelationsByTypeInRangeSQL = "" +
|
const selectRelationsByTypeInRangeSQL = "" +
|
||||||
"SELECT id, room_id, child_event_id, rel_type FROM syncapi_relations" +
|
"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"
|
" ORDER BY id DESC LIMIT $6"
|
||||||
|
|
||||||
const selectMaxRelationIDSQL = "" +
|
const selectMaxRelationIDSQL = "" +
|
||||||
|
|
|
||||||
|
|
@ -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 there were no entries returned, there were no relations, so stop at this point.
|
||||||
if len(entries) == 0 {
|
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
|
// Otherwise, let's try and work out what sensible prev_batch and next_batch values
|
||||||
|
|
|
||||||
|
|
@ -48,12 +48,12 @@ const deleteRelationSQL = "" +
|
||||||
|
|
||||||
const selectRelationsInRangeSQL = "" +
|
const selectRelationsInRangeSQL = "" +
|
||||||
"SELECT id, room_id, child_event_id, rel_type FROM syncapi_relations" +
|
"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"
|
" ORDER BY id DESC LIMIT $5"
|
||||||
|
|
||||||
const selectRelationsByTypeInRangeSQL = "" +
|
const selectRelationsByTypeInRangeSQL = "" +
|
||||||
"SELECT id, room_id, child_event_id, rel_type FROM syncapi_relations" +
|
"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"
|
" ORDER BY id DESC LIMIT $6"
|
||||||
|
|
||||||
const selectMaxRelationIDSQL = "" +
|
const selectMaxRelationIDSQL = "" +
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue