mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-13 01:43:09 -06:00
Replace QueryPreviousEvents with QueryBackfill
This commit is contained in:
parent
5891a0d078
commit
77366c2bab
|
|
@ -31,7 +31,7 @@ func Backfill(
|
|||
query api.RoomserverQueryAPI,
|
||||
roomID string,
|
||||
) util.JSONResponse {
|
||||
var res api.QueryPreviousEventsResponse
|
||||
var res api.QueryBackfillResponse
|
||||
var eIDs []string
|
||||
var limit string
|
||||
var exists bool
|
||||
|
|
@ -62,7 +62,7 @@ func Backfill(
|
|||
}
|
||||
|
||||
// Populate the request.
|
||||
req := api.QueryPreviousEventsRequest{
|
||||
req := api.QueryBackfillRequest{
|
||||
EarliestEventsIDs: eIDs,
|
||||
ServerName: request.Origin(),
|
||||
}
|
||||
|
|
@ -71,7 +71,7 @@ func Backfill(
|
|||
}
|
||||
|
||||
// Query the roomserver.
|
||||
if err = query.QueryPreviousEvents(httpReq.Context(), &req, &res); err != nil {
|
||||
if err = query.QueryBackfill(httpReq.Context(), &req, &res); err != nil {
|
||||
return httputil.LogThenError(httpReq, err)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -214,8 +214,8 @@ type QueryStateAndAuthChainResponse struct {
|
|||
AuthChainEvents []gomatrixserverlib.Event `json:"auth_chain_events"`
|
||||
}
|
||||
|
||||
// QueryPreviousEventsRequest is a request to QueryPreviousEvents.
|
||||
type QueryPreviousEventsRequest struct {
|
||||
// QueryBackfillRequest is a request to QueryBackfill.
|
||||
type QueryBackfillRequest struct {
|
||||
// Events to start paginating from.
|
||||
EarliestEventsIDs []string `json:"earliest_event_ids"`
|
||||
// The maximum number of events to retrieve.
|
||||
|
|
@ -224,8 +224,8 @@ type QueryPreviousEventsRequest struct {
|
|||
ServerName gomatrixserverlib.ServerName `json:"server_name"`
|
||||
}
|
||||
|
||||
// QueryPreviousEventsResponse is a response to QueryPreviousEvents.
|
||||
type QueryPreviousEventsResponse struct {
|
||||
// QueryBackfillResponse is a response to QueryBackfill.
|
||||
type QueryBackfillResponse struct {
|
||||
// Missing events, arbritrary order.
|
||||
Events []gomatrixserverlib.Event `json:"events"`
|
||||
}
|
||||
|
|
@ -298,10 +298,10 @@ type RoomserverQueryAPI interface {
|
|||
) error
|
||||
|
||||
// Query a given amount (or less) of events prior to a given set of events.
|
||||
QueryPreviousEvents(
|
||||
QueryBackfill(
|
||||
ctx context.Context,
|
||||
request *QueryPreviousEventsRequest,
|
||||
response *QueryPreviousEventsResponse,
|
||||
request *QueryBackfillRequest,
|
||||
response *QueryBackfillResponse,
|
||||
) error
|
||||
}
|
||||
|
||||
|
|
@ -332,8 +332,8 @@ const RoomserverQueryMissingEventsPath = "/api/roomserver/queryMissingEvents"
|
|||
// RoomserverQueryStateAndAuthChainPath is the HTTP path for the QueryStateAndAuthChain API
|
||||
const RoomserverQueryStateAndAuthChainPath = "/api/roomserver/queryStateAndAuthChain"
|
||||
|
||||
// RoomserverQueryPreviousEventsPath is the HTTP path for the QueryMissingEvents API
|
||||
const RoomserverQueryPreviousEventsPath = "/api/roomserver/queryPreviousEvents"
|
||||
// RoomserverQueryBackfillPath is the HTTP path for the QueryMissingEvents API
|
||||
const RoomserverQueryBackfillPath = "/api/roomserver/QueryBackfill"
|
||||
|
||||
// NewRoomserverQueryAPIHTTP creates a RoomserverQueryAPI implemented by talking to a HTTP POST API.
|
||||
// If httpClient is nil then it uses the http.DefaultClient
|
||||
|
|
@ -466,13 +466,13 @@ func (h *httpRoomserverQueryAPI) QueryStateAndAuthChain(
|
|||
return commonHTTP.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
|
||||
}
|
||||
|
||||
// QueryPreviousEvents implements RoomServerQueryAPI
|
||||
func (h *httpRoomserverQueryAPI) QueryPreviousEvents(
|
||||
// QueryBackfill implements RoomServerQueryAPI
|
||||
func (h *httpRoomserverQueryAPI) QueryBackfill(
|
||||
ctx context.Context,
|
||||
request *QueryPreviousEventsRequest,
|
||||
response *QueryPreviousEventsResponse,
|
||||
request *QueryBackfillRequest,
|
||||
response *QueryBackfillResponse,
|
||||
) error {
|
||||
span, ctx := opentracing.StartSpanFromContext(ctx, "QueryPreviousEvents")
|
||||
span, ctx := opentracing.StartSpanFromContext(ctx, "QueryBackfill")
|
||||
defer span.Finish()
|
||||
|
||||
apiURL := h.roomserverURL + RoomserverQueryMissingEventsPath
|
||||
|
|
|
|||
|
|
@ -458,11 +458,11 @@ func (r *RoomserverQueryAPI) QueryMissingEvents(
|
|||
return err
|
||||
}
|
||||
|
||||
// QueryPreviousEvents implements api.RoomServerQueryAPI
|
||||
func (r *RoomserverQueryAPI) QueryPreviousEvents(
|
||||
// QueryBackfill implements api.RoomServerQueryAPI
|
||||
func (r *RoomserverQueryAPI) QueryBackfill(
|
||||
ctx context.Context,
|
||||
request *api.QueryPreviousEventsRequest,
|
||||
response *api.QueryPreviousEventsResponse,
|
||||
request *api.QueryBackfillRequest,
|
||||
response *api.QueryBackfillResponse,
|
||||
) error {
|
||||
var err error
|
||||
var front []string
|
||||
|
|
@ -773,14 +773,14 @@ func (r *RoomserverQueryAPI) SetupHTTP(servMux *http.ServeMux) {
|
|||
}),
|
||||
)
|
||||
servMux.Handle(
|
||||
api.RoomserverQueryPreviousEventsPath,
|
||||
common.MakeInternalAPI("queryPreviousEvents", func(req *http.Request) util.JSONResponse {
|
||||
var request api.QueryPreviousEventsRequest
|
||||
var response api.QueryPreviousEventsResponse
|
||||
api.RoomserverQueryBackfillPath,
|
||||
common.MakeInternalAPI("QueryBackfill", func(req *http.Request) util.JSONResponse {
|
||||
var request api.QueryBackfillRequest
|
||||
var response api.QueryBackfillResponse
|
||||
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
|
||||
return util.ErrorResponse(err)
|
||||
}
|
||||
if err := r.QueryPreviousEvents(req.Context(), &request, &response); err != nil {
|
||||
if err := r.QueryBackfill(req.Context(), &request, &response); err != nil {
|
||||
return util.ErrorResponse(err)
|
||||
}
|
||||
return util.JSONResponse{Code: http.StatusOK, JSON: &response}
|
||||
|
|
|
|||
Loading…
Reference in a new issue