func MakeJoinRequestsHandler(s *Server, w http.ResponseWriter, req *http.Request) {
	// Check federation signature
	fedReq, errResp := gomatrixserverlib.VerifyHTTPRequest(
		req, time.Now(), gomatrixserverlib.ServerName(s.ServerName), s.keyRing,
	)
	if fedReq == nil {
		w.WriteHeader(errResp.Code)
		b, _ := json.Marshal(errResp.JSON)
		w.Write(b)
		return
	}

	vars := mux.Vars(req)
	userID := vars["userID"]
	roomID := vars["roomID"]

	room, ok := s.rooms[roomID]
	if !ok {
		w.WriteHeader(404)
		w.Write([]byte("complement: HandleMakeSendJoinRequests make_join unexpected room ID: " + roomID))
		return
	}

	// Generate a join event
	builder := gomatrixserverlib.EventBuilder{
		Sender:     userID,
		RoomID:     roomID,
		Type:       "m.room.member",
		StateKey:   &userID,
		PrevEvents: []string{room.Timeline[len(room.Timeline)-1].EventID()},
	}
	err := builder.SetContent(map[string]interface{}{"membership": gomatrixserverlib.Join})
	if err != nil {
		w.WriteHeader(500)
		w.Write([]byte("complement: HandleMakeSendJoinRequests make_join cannot set membership content: " + err.Error()))
		return
	}
	stateNeeded, err := gomatrixserverlib.StateNeededForEventBuilder(&builder)
	if err != nil {
		w.WriteHeader(500)
		w.Write([]byte("complement: HandleMakeSendJoinRequests make_join cannot calculate auth_events: " + err.Error()))
		return
	}
	builder.AuthEvents = room.AuthEvents(stateNeeded)

	// Send it
	res := map[string]interface{}{
		"event":        builder,
		"room_version": room.Version,
	}
	w.WriteHeader(200)
	b, _ := json.Marshal(res)
	w.Write(b)
}
// MakeJoinRequestsHandler is the http.Handler implementation for the make_join part of
// HandleMakeSendJoinRequests.
MakeJoinRequestsHandler is the http.Handler implementation for the make_join part of
HandleMakeSendJoinRequests.
// MakeJoinRequestsHandler is the http . Handler implementation for the make_join part of // HandleMakeSendJoinRequests .
func MakeJoinRequestsHandler(s *Server, w http.ResponseWriter, req *http.Request) {
	fedReq, errResp := gomatrixserverlib.VerifyHTTPRequest(
		req, time.Now(), gomatrixserverlib.ServerName(s.ServerName), s.keyRing,
	)
	if fedReq == nil {
		w.WriteHeader(errResp.Code)
		b, _ := json.Marshal(errResp.JSON)
		w.Write(b)
		return
	}
	vars := mux.Vars(req)
	userID := vars["userID"]
	roomID := vars["roomID"]
	room, ok := s.rooms[roomID]
	if !ok {
		w.WriteHeader(404)
		w.Write([]byte("complement: HandleMakeSendJoinRequests make_join unexpected room ID: " + roomID))
		return
	}
	builder := gomatrixserverlib.EventBuilder{
		Sender:     userID,
		RoomID:     roomID,
		Type:       "m.room.member",
		StateKey:   &userID,
		PrevEvents: []string{room.Timeline[len(room.Timeline)-1].EventID()},
	}
	err := builder.SetContent(map[string]interface{}{"membership": gomatrixserverlib.Join})
	if err != nil {
		w.WriteHeader(500)
		w.Write([]byte("complement: HandleMakeSendJoinRequests make_join cannot set membership content: " + err.Error()))
		return
	}
	stateNeeded, err := gomatrixserverlib.StateNeededForEventBuilder(&builder)
	if err != nil {
		w.WriteHeader(500)
		w.Write([]byte("complement: HandleMakeSendJoinRequests make_join cannot calculate auth_events: " + err.Error()))
		return
	}
	builder.AuthEvents = room.AuthEvents(stateNeeded)
	res := map[string]interface{}{
		"event":        builder,
		"room_version": room.Version,
	}
	w.WriteHeader(200)
	b, _ := json.Marshal(res)
	w.Write(b)
}
func MakeJoinRequestsHandler ( s * Server , w http . ResponseWriter , req * http . Request ) { fedReq , errResp := gomatrixserverlib . VerifyHTTPRequest ( req , time . Now ( ) , gomatrixserverlib . ServerName ( s . ServerName ) , s . keyRing , ) if fedReq == nil { w . WriteHeader ( errResp . Code ) b , _ := json . Marshal ( errResp . JSON ) w . Write ( b ) return } vars := mux . Vars ( req ) userID := vars [ " " ] roomID := vars [ " " ] room , ok := s . rooms [ roomID ] if ! ok { w . WriteHeader ( 404 ) w . Write ( [ ] byte ( " " + roomID ) ) return } builder := gomatrixserverlib . EventBuilder { Sender : userID , RoomID : roomID , Type : " " , StateKey : & userID , PrevEvents : [ ] string { room . Timeline [ len ( room . Timeline ) - 1 ] . EventID ( ) } , } err := builder . SetContent ( map [ string ] interface { } { " " : gomatrixserverlib . Join } ) if err != nil { w . WriteHeader ( 500 ) w . Write ( [ ] byte ( " " + err . Error ( ) ) ) return } stateNeeded , err := gomatrixserverlib . StateNeededForEventBuilder ( & builder ) if err != nil { w . WriteHeader ( 500 ) w . Write ( [ ] byte ( " " + err . Error ( ) ) ) return } builder . AuthEvents = room . AuthEvents ( stateNeeded ) res := map [ string ] interface { } { " " : builder , " " : room . Version , } w . WriteHeader ( 200 ) b , _ := json . Marshal ( res ) w . Write ( b ) }
MakeJoinRequestsHandler is the http.Handler implementation for the make_join part of
HandleMakeSendJoinRequests.
MakeJoinRequestsHandler is the http . Handler implementation for the make_join part of HandleMakeSendJoinRequests .
// Check federation signature // Generate a join event // Send it