MCPcopy Create free account
hub / github.com/daodst/chat / ErrorIfLocalServerNotInRoom

Function ErrorIfLocalServerNotInRoom

federationapi/routing/routing.go:502–524  ·  view source on GitHub ↗
(
	ctx context.Context,
	rsAPI api.FederationRoomserverAPI,
	roomID string,
)

Source from the content-addressed store, hash-verified

500}
501
502func 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.
527func MakeFedAPI(

Callers 4

BackfillFunction · 0.85
GetEventAuthFunction · 0.85
GetMissingEventsFunction · 0.85
getStateFunction · 0.85

Calls 1

Tested by

no test coverage detected