( ctx context.Context, rsAPI api.FederationRoomserverAPI, roomID string, )
| 500 | } |
| 501 | |
| 502 | func ErrorIfLocalServerNotInRoom( |
| 503 | ctx context.Context, |
| 504 | rsAPI api.FederationRoomserverAPI, |
| 505 | roomID string, |
| 506 | ) *util.JSONResponse { |
| 507 | // Check if we think we're in this room. If we aren't then |
| 508 | // we won't waste CPU cycles serving this request. |
| 509 | joinedReq := &api.QueryServerJoinedToRoomRequest{ |
| 510 | RoomID: roomID, |
| 511 | } |
| 512 | joinedRes := &api.QueryServerJoinedToRoomResponse{} |
| 513 | if err := rsAPI.QueryServerJoinedToRoom(ctx, joinedReq, joinedRes); err != nil { |
| 514 | res := util.ErrorResponse(err) |
| 515 | return &res |
| 516 | } |
| 517 | if !joinedRes.IsInRoom { |
| 518 | return &util.JSONResponse{ |
| 519 | Code: http.StatusNotFound, |
| 520 | JSON: jsonerror.NotFound(fmt.Sprintf("This server is not joined to room %s", roomID)), |
| 521 | } |
| 522 | } |
| 523 | return nil |
| 524 | } |
| 525 | |
| 526 | // MakeFedAPI makes an http.Handler that checks matrix federation authentication. |
| 527 | func MakeFedAPI( |
no test coverage detected