InviteV2 implements /_matrix/federation/v2/invite/{roomID}/{eventID}
( // api,TODO ,then auto join room!, httpReq *http.Request, request *gomatrixserverlib.FederationRequest, roomID string, eventID string, cfg *config.FederationAPI, rsAPI api.FederationRoomserverAPI, keys gomatrixserverlib.JSONVerifier, )
| 30 | |
| 31 | // InviteV2 implements /_matrix/federation/v2/invite/{roomID}/{eventID} |
| 32 | func InviteV2( // api,TODO ,then auto join room!, |
| 33 | httpReq *http.Request, |
| 34 | request *gomatrixserverlib.FederationRequest, |
| 35 | roomID string, |
| 36 | eventID string, |
| 37 | cfg *config.FederationAPI, |
| 38 | rsAPI api.FederationRoomserverAPI, |
| 39 | keys gomatrixserverlib.JSONVerifier, |
| 40 | ) util.JSONResponse { |
| 41 | inviteReq := gomatrixserverlib.InviteV2Request{} |
| 42 | err := json.Unmarshal(request.Content(), &inviteReq) |
| 43 | switch e := err.(type) { |
| 44 | case gomatrixserverlib.UnsupportedRoomVersionError: |
| 45 | return util.JSONResponse{ |
| 46 | Code: http.StatusBadRequest, |
| 47 | JSON: jsonerror.UnsupportedRoomVersion( |
| 48 | fmt.Sprintf("Room version %q is not supported by this server.", e.Version), |
| 49 | ), |
| 50 | } |
| 51 | case gomatrixserverlib.BadJSONError: |
| 52 | return util.JSONResponse{ |
| 53 | Code: http.StatusBadRequest, |
| 54 | JSON: jsonerror.BadJSON(err.Error()), |
| 55 | } |
| 56 | case nil: |
| 57 | res1 := processInvite( |
| 58 | httpReq.Context(), true, inviteReq.Event(), inviteReq.RoomVersion(), inviteReq.InviteRoomState(), roomID, eventID, cfg, rsAPI, keys, |
| 59 | ) |
| 60 | |
| 61 | return res1 |
| 62 | default: |
| 63 | return util.JSONResponse{ |
| 64 | Code: http.StatusBadRequest, |
| 65 | JSON: jsonerror.NotJSON("The request body could not be decoded into an invite request. " + err.Error()), |
| 66 | } |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | // InviteV1 implements /_matrix/federation/v1/invite/{roomID}/{eventID} |
| 71 | func InviteV1( |
no test coverage detected