mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-01 03:03:10 -06:00
tweaks
This commit is contained in:
parent
02fdce5296
commit
ba7a542548
|
|
@ -49,6 +49,7 @@ type messagesReq struct {
|
||||||
|
|
||||||
type messagesResp struct {
|
type messagesResp struct {
|
||||||
Start string `json:"start"`
|
Start string `json:"start"`
|
||||||
|
StartStream string `json:"start_stream,omitempty"` // NOTSPEC: used by Cerulean, so clients can hit /messages then immediately /sync with a latest sync token
|
||||||
End string `json:"end"`
|
End string `json:"end"`
|
||||||
Chunk []gomatrixserverlib.ClientEvent `json:"chunk"`
|
Chunk []gomatrixserverlib.ClientEvent `json:"chunk"`
|
||||||
State []gomatrixserverlib.ClientEvent `json:"state"`
|
State []gomatrixserverlib.ClientEvent `json:"state"`
|
||||||
|
|
@ -89,6 +90,7 @@ func OnIncomingMessagesRequest(
|
||||||
|
|
||||||
// Extract parameters from the request's URL.
|
// Extract parameters from the request's URL.
|
||||||
// Pagination tokens.
|
// Pagination tokens.
|
||||||
|
var fromStream *types.StreamingToken
|
||||||
fromQuery := req.URL.Query().Get("from")
|
fromQuery := req.URL.Query().Get("from")
|
||||||
toQuery := req.URL.Query().Get("to")
|
toQuery := req.URL.Query().Get("to")
|
||||||
emptyFromSupplied := fromQuery == ""
|
emptyFromSupplied := fromQuery == ""
|
||||||
|
|
@ -120,6 +122,7 @@ func OnIncomingMessagesRequest(
|
||||||
JSON: jsonerror.InvalidArgumentValue("Invalid from parameter: " + err.Error()),
|
JSON: jsonerror.InvalidArgumentValue("Invalid from parameter: " + err.Error()),
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
fromStream = &streamToken
|
||||||
from, err = db.StreamToTopologicalPosition(req.Context(), roomID, streamToken.PDUPosition, backwardOrdering)
|
from, err = db.StreamToTopologicalPosition(req.Context(), roomID, streamToken.PDUPosition, backwardOrdering)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.WithError(err).Errorf("Failed to get topological position for streaming token %v", streamToken)
|
logrus.WithError(err).Errorf("Failed to get topological position for streaming token %v", streamToken)
|
||||||
|
|
@ -226,6 +229,9 @@ func OnIncomingMessagesRequest(
|
||||||
End: end.String(),
|
End: end.String(),
|
||||||
State: state,
|
State: state,
|
||||||
}
|
}
|
||||||
|
if fromStream != nil {
|
||||||
|
res.StartStream = fromStream.String()
|
||||||
|
}
|
||||||
|
|
||||||
// Respond with the events.
|
// Respond with the events.
|
||||||
return util.JSONResponse{
|
return util.JSONResponse{
|
||||||
|
|
|
||||||
|
|
@ -50,14 +50,14 @@ const insertEventInTopologySQL = "" +
|
||||||
const selectEventIDsInRangeASCSQL = "" +
|
const selectEventIDsInRangeASCSQL = "" +
|
||||||
"SELECT event_id FROM syncapi_output_room_events_topology" +
|
"SELECT event_id FROM syncapi_output_room_events_topology" +
|
||||||
" WHERE room_id = $1 AND (" +
|
" WHERE room_id = $1 AND (" +
|
||||||
"(topological_position > $2 AND topological_position <= $3) OR" +
|
"(topological_position > $2 AND topological_position < $3) OR" +
|
||||||
"(topological_position = $4 AND stream_position <= $5)" +
|
"(topological_position = $4 AND stream_position <= $5)" +
|
||||||
") ORDER BY topological_position ASC, stream_position ASC LIMIT $6"
|
") ORDER BY topological_position ASC, stream_position ASC LIMIT $6"
|
||||||
|
|
||||||
const selectEventIDsInRangeDESCSQL = "" +
|
const selectEventIDsInRangeDESCSQL = "" +
|
||||||
"SELECT event_id FROM syncapi_output_room_events_topology" +
|
"SELECT event_id FROM syncapi_output_room_events_topology" +
|
||||||
" WHERE room_id = $1 AND (" +
|
" WHERE room_id = $1 AND (" +
|
||||||
"(topological_position >= $2 AND topological_position < $3) OR" +
|
"(topological_position > $2 AND topological_position < $3) OR" +
|
||||||
"(topological_position = $4 AND stream_position <= $5)" +
|
"(topological_position = $4 AND stream_position <= $5)" +
|
||||||
") ORDER BY topological_position DESC, stream_position DESC LIMIT $6"
|
") ORDER BY topological_position DESC, stream_position DESC LIMIT $6"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,14 +46,14 @@ const insertEventInTopologySQL = "" +
|
||||||
const selectEventIDsInRangeASCSQL = "" +
|
const selectEventIDsInRangeASCSQL = "" +
|
||||||
"SELECT event_id FROM syncapi_output_room_events_topology" +
|
"SELECT event_id FROM syncapi_output_room_events_topology" +
|
||||||
" WHERE room_id = $1 AND (" +
|
" WHERE room_id = $1 AND (" +
|
||||||
"(topological_position > $2 AND topological_position <= $3) OR" +
|
"(topological_position > $2 AND topological_position < $3) OR" +
|
||||||
"(topological_position = $4 AND stream_position <= $5)" +
|
"(topological_position = $4 AND stream_position <= $5)" +
|
||||||
") ORDER BY topological_position ASC, stream_position ASC LIMIT $6"
|
") ORDER BY topological_position ASC, stream_position ASC LIMIT $6"
|
||||||
|
|
||||||
const selectEventIDsInRangeDESCSQL = "" +
|
const selectEventIDsInRangeDESCSQL = "" +
|
||||||
"SELECT event_id FROM syncapi_output_room_events_topology" +
|
"SELECT event_id FROM syncapi_output_room_events_topology" +
|
||||||
" WHERE room_id = $1 AND (" +
|
" WHERE room_id = $1 AND (" +
|
||||||
"(topological_position >= $2 AND topological_position < $3) OR" +
|
"(topological_position > $2 AND topological_position < $3) OR" +
|
||||||
"(topological_position = $4 AND stream_position <= $5)" +
|
"(topological_position = $4 AND stream_position <= $5)" +
|
||||||
") ORDER BY topological_position DESC, stream_position DESC LIMIT $6"
|
") ORDER BY topological_position DESC, stream_position DESC LIMIT $6"
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue