mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-10 15:43:09 -06:00
Add make/send invite federation endpoints
This commit is contained in:
parent
45082d4dce
commit
0e1b81bb4e
|
|
@ -246,3 +246,29 @@ func handleInvite(ctx context.Context, input gomatrixserverlib.HandleInviteInput
|
||||||
}
|
}
|
||||||
return inviteEvent, nil
|
return inviteEvent, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MakeInvite implements /_matrix/federation/v2/make_invite/{roomID}/{userID}
|
||||||
|
func MakeInvite(
|
||||||
|
httpReq *http.Request,
|
||||||
|
request *fclient.FederationRequest,
|
||||||
|
roomID spec.RoomID,
|
||||||
|
userID spec.UserID,
|
||||||
|
cfg *config.FederationAPI,
|
||||||
|
rsAPI api.FederationRoomserverAPI,
|
||||||
|
keys gomatrixserverlib.JSONVerifier,
|
||||||
|
) util.JSONResponse {
|
||||||
|
return util.JSONResponse{}
|
||||||
|
}
|
||||||
|
|
||||||
|
// SendInvite implements /_matrix/federation/v2/send_invite/{roomID}/{eventID}
|
||||||
|
func SendInvite(
|
||||||
|
httpReq *http.Request,
|
||||||
|
request *fclient.FederationRequest,
|
||||||
|
roomID spec.RoomID,
|
||||||
|
eventID string,
|
||||||
|
cfg *config.FederationAPI,
|
||||||
|
rsAPI api.FederationRoomserverAPI,
|
||||||
|
keys gomatrixserverlib.JSONVerifier,
|
||||||
|
) util.JSONResponse {
|
||||||
|
return util.JSONResponse{}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -191,6 +191,61 @@ func Setup(
|
||||||
},
|
},
|
||||||
)).Methods(http.MethodPut, http.MethodOptions)
|
)).Methods(http.MethodPut, http.MethodOptions)
|
||||||
|
|
||||||
|
v2fedmux.Handle("/make_invite/{roomID}/{userID}", MakeFedAPI(
|
||||||
|
"federation_make_invite", cfg.Matrix.ServerName, cfg.Matrix.IsLocalServerName, keys, wakeup,
|
||||||
|
func(httpReq *http.Request, request *fclient.FederationRequest, vars map[string]string) util.JSONResponse {
|
||||||
|
if roomserverAPI.IsServerBannedFromRoom(httpReq.Context(), rsAPI, vars["roomID"], request.Origin()) {
|
||||||
|
return util.JSONResponse{
|
||||||
|
Code: http.StatusForbidden,
|
||||||
|
JSON: spec.Forbidden("Forbidden by server ACLs"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
userID, err := spec.NewUserID(vars["userID"], true)
|
||||||
|
if err != nil {
|
||||||
|
return util.JSONResponse{
|
||||||
|
Code: http.StatusBadRequest,
|
||||||
|
JSON: spec.InvalidParam("Invalid UserID"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
roomID, err := spec.NewRoomID(vars["roomID"])
|
||||||
|
if err != nil {
|
||||||
|
return util.JSONResponse{
|
||||||
|
Code: http.StatusBadRequest,
|
||||||
|
JSON: spec.InvalidParam("Invalid RoomID"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return MakeInvite(
|
||||||
|
httpReq, request, *roomID, *userID,
|
||||||
|
cfg, rsAPI, keys,
|
||||||
|
)
|
||||||
|
},
|
||||||
|
)).Methods(http.MethodGet, http.MethodOptions)
|
||||||
|
|
||||||
|
v2fedmux.Handle("/send_invite/{roomID}/{eventID}", MakeFedAPI(
|
||||||
|
"federation_send_invite", cfg.Matrix.ServerName, cfg.Matrix.IsLocalServerName, keys, wakeup,
|
||||||
|
func(httpReq *http.Request, request *fclient.FederationRequest, vars map[string]string) util.JSONResponse {
|
||||||
|
if roomserverAPI.IsServerBannedFromRoom(httpReq.Context(), rsAPI, vars["roomID"], request.Origin()) {
|
||||||
|
return util.JSONResponse{
|
||||||
|
Code: http.StatusForbidden,
|
||||||
|
JSON: spec.Forbidden("Forbidden by server ACLs"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
roomID, err := spec.NewRoomID(vars["roomID"])
|
||||||
|
if err != nil {
|
||||||
|
return util.JSONResponse{
|
||||||
|
Code: http.StatusBadRequest,
|
||||||
|
JSON: spec.InvalidParam("Invalid RoomID"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return SendInvite(
|
||||||
|
httpReq, request, *roomID, vars["eventID"],
|
||||||
|
cfg, rsAPI, keys,
|
||||||
|
)
|
||||||
|
},
|
||||||
|
)).Methods(http.MethodPut, http.MethodOptions)
|
||||||
|
|
||||||
v1fedmux.Handle("/3pid/onbind", httputil.MakeExternalAPI("3pid_onbind",
|
v1fedmux.Handle("/3pid/onbind", httputil.MakeExternalAPI("3pid_onbind",
|
||||||
func(req *http.Request) util.JSONResponse {
|
func(req *http.Request) util.JSONResponse {
|
||||||
return CreateInvitesFrom3PIDInvites(req, rsAPI, cfg, federation, userAPI)
|
return CreateInvitesFrom3PIDInvites(req, rsAPI, cfg, federation, userAPI)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue