mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-29 09:43:10 -06:00
Make full HTTP tests less upsetti
This commit is contained in:
parent
80e015a7e8
commit
deae1d08d8
|
|
@ -360,14 +360,16 @@ type lookupMissingEvents struct {
|
|||
RoomID string
|
||||
Missing gomatrixserverlib.MissingEvents
|
||||
RoomVersion gomatrixserverlib.RoomVersion
|
||||
Res *gomatrixserverlib.RespMissingEvents
|
||||
Err *api.FederationClientError
|
||||
Res struct {
|
||||
Events []gomatrixserverlib.RawJSON `json:"events"`
|
||||
}
|
||||
Err *api.FederationClientError
|
||||
}
|
||||
|
||||
func (h *httpFederationInternalAPI) LookupMissingEvents(
|
||||
ctx context.Context, s gomatrixserverlib.ServerName, roomID string,
|
||||
missing gomatrixserverlib.MissingEvents, roomVersion gomatrixserverlib.RoomVersion,
|
||||
) (gomatrixserverlib.RespMissingEvents, error) {
|
||||
) (res gomatrixserverlib.RespMissingEvents, err error) {
|
||||
span, ctx := opentracing.StartSpanFromContext(ctx, "LookupMissingEvents")
|
||||
defer span.Finish()
|
||||
|
||||
|
|
@ -377,16 +379,23 @@ func (h *httpFederationInternalAPI) LookupMissingEvents(
|
|||
Missing: missing,
|
||||
RoomVersion: roomVersion,
|
||||
}
|
||||
var response lookupMissingEvents
|
||||
apiURL := h.federationAPIURL + FederationAPILookupMissingEventsPath
|
||||
err := httputil.PostJSON(ctx, span, h.httpClient, apiURL, &request, &response)
|
||||
err = httputil.PostJSON(ctx, span, h.httpClient, apiURL, &request, &request)
|
||||
if err != nil {
|
||||
return gomatrixserverlib.RespMissingEvents{}, err
|
||||
return res, err
|
||||
}
|
||||
if response.Err != nil {
|
||||
return gomatrixserverlib.RespMissingEvents{}, response.Err
|
||||
if request.Err != nil {
|
||||
return res, request.Err
|
||||
}
|
||||
return *response.Res, nil
|
||||
res.Events = make([]*gomatrixserverlib.Event, 0, len(request.Res.Events))
|
||||
for _, js := range request.Res.Events {
|
||||
ev, err := gomatrixserverlib.NewEventFromUntrustedJSON(js, roomVersion)
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
res.Events = append(res.Events, ev)
|
||||
}
|
||||
return res, nil
|
||||
}
|
||||
|
||||
type getEvent struct {
|
||||
|
|
|
|||
|
|
@ -259,7 +259,13 @@ func AddRoutes(intAPI api.FederationInternalAPI, internalAPIMux *mux.Router) {
|
|||
}
|
||||
}
|
||||
}
|
||||
request.Res = &res
|
||||
for _, event := range res.Events {
|
||||
js, err := json.Marshal(event)
|
||||
if err != nil {
|
||||
return util.MessageResponse(http.StatusInternalServerError, err.Error())
|
||||
}
|
||||
request.Res.Events = append(request.Res.Events, js)
|
||||
}
|
||||
return util.JSONResponse{Code: http.StatusOK, JSON: request}
|
||||
}),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -101,6 +101,10 @@ func (r *Inputer) processRoomEvent(
|
|||
"type": event.Type(),
|
||||
})
|
||||
|
||||
if _, err := headered.RoomVersion.EventIDFormat(); err != nil {
|
||||
panic("UNKNOWN ROOM VERSION")
|
||||
}
|
||||
|
||||
// if we have already got this event then do not process it again, if the input kind is an outlier.
|
||||
// Outliers contain no extra information which may warrant a re-processing.
|
||||
if input.Kind == api.KindOutlier {
|
||||
|
|
|
|||
Loading…
Reference in a new issue