Tweak federation `M_NOT_FOUND` errors
MODIFY
federationapi/routing/events.go
federationapi/routing/events.go
@@ -20,6 +20,7 @@ import (
"net/http"
"time"
+ "github.com/matrix-org/dendrite/clientapi/jsonerror"
"github.com/matrix-org/dendrite/roomserver/api"
"github.com/matrix-org/gomatrixserverlib"
"github.com/matrix-org/util"
@@ -95,7 +96,10 @@ func fetchEvent(ctx context.Context, rsAPI api.FederationRoomserverAPI, eventID
}
if len(eventsResponse.Events) == 0 {
- return nil, &util.JSONResponse{Code: http.StatusNotFound, JSON: nil}
+ return nil, &util.JSONResponse{
+ Code: http.StatusNotFound,
+ JSON: jsonerror.NotFound("Event not found"),
+ }
}
return eventsResponse.Events[0].Event, nil

MODIFY
federationapi/routing/state.go
federationapi/routing/state.go
@@ -135,23 +135,24 @@ func getState(
return nil, nil, &resErr
}
- if !response.StateKnown {
+ switch {
+ case !response.RoomExists:
return nil, nil, &util.JSONResponse{
Code: http.StatusNotFound,
- JSON: jsonerror.NotFound("State not known"),
+ JSON: jsonerror.NotFound("Room not found"),
}
+ case !response.StateKnown:
+ return nil, nil, &util.JSONResponse{
+ Code: http.StatusNotFound,
+ JSON: jsonerror.NotFound("State not known"),
}
- if response.IsRejected {
+ case response.IsRejected:
return nil, nil, &util.JSONResponse{
Code: http.StatusNotFound,
JSON: jsonerror.NotFound("Event not found"),
}
}
- if !response.RoomExists {
- return nil, nil, &util.JSONResponse{Code: http.StatusNotFound, JSON: nil}
- }
-
return response.StateEvents, response.AuthChainEvents, nil
}

Tweak federation `M_NOT_FOUND` errors