mirror of
https://github.com/matrix-org/dendrite
synced 2024-11-18 07:40:53 +01:00
Tweak federation M_NOT_FOUND
errors
This commit is contained in:
parent
6bf1912525
commit
9ed8ff6b93
2 changed files with 13 additions and 8 deletions
|
@ -20,6 +20,7 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/matrix-org/dendrite/clientapi/jsonerror"
|
||||||
"github.com/matrix-org/dendrite/roomserver/api"
|
"github.com/matrix-org/dendrite/roomserver/api"
|
||||||
"github.com/matrix-org/gomatrixserverlib"
|
"github.com/matrix-org/gomatrixserverlib"
|
||||||
"github.com/matrix-org/util"
|
"github.com/matrix-org/util"
|
||||||
|
@ -95,7 +96,10 @@ func fetchEvent(ctx context.Context, rsAPI api.FederationRoomserverAPI, eventID
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(eventsResponse.Events) == 0 {
|
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
|
return eventsResponse.Events[0].Event, nil
|
||||||
|
|
|
@ -135,23 +135,24 @@ func getState(
|
||||||
return nil, nil, &resErr
|
return nil, nil, &resErr
|
||||||
}
|
}
|
||||||
|
|
||||||
if !response.StateKnown {
|
switch {
|
||||||
|
case !response.RoomExists:
|
||||||
|
return nil, nil, &util.JSONResponse{
|
||||||
|
Code: http.StatusNotFound,
|
||||||
|
JSON: jsonerror.NotFound("Room not found"),
|
||||||
|
}
|
||||||
|
case !response.StateKnown:
|
||||||
return nil, nil, &util.JSONResponse{
|
return nil, nil, &util.JSONResponse{
|
||||||
Code: http.StatusNotFound,
|
Code: http.StatusNotFound,
|
||||||
JSON: jsonerror.NotFound("State not known"),
|
JSON: jsonerror.NotFound("State not known"),
|
||||||
}
|
}
|
||||||
}
|
case response.IsRejected:
|
||||||
if response.IsRejected {
|
|
||||||
return nil, nil, &util.JSONResponse{
|
return nil, nil, &util.JSONResponse{
|
||||||
Code: http.StatusNotFound,
|
Code: http.StatusNotFound,
|
||||||
JSON: jsonerror.NotFound("Event not found"),
|
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
|
return response.StateEvents, response.AuthChainEvents, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue