InviteV1 implements /_matrix/federation/v1/invite/{roomID}/{eventID}
( httpReq *http.Request, request *gomatrixserverlib.FederationRequest, roomID string, eventID string, cfg *config.FederationAPI, rsAPI api.FederationRoomserverAPI, keys gomatrixserverlib.JSONVerifier, )
| 69 | |
| 70 | // InviteV1 implements /_matrix/federation/v1/invite/{roomID}/{eventID} |
| 71 | func InviteV1( |
| 72 | httpReq *http.Request, |
| 73 | request *gomatrixserverlib.FederationRequest, |
| 74 | roomID string, |
| 75 | eventID string, |
| 76 | cfg *config.FederationAPI, |
| 77 | rsAPI api.FederationRoomserverAPI, |
| 78 | keys gomatrixserverlib.JSONVerifier, |
| 79 | ) util.JSONResponse { |
| 80 | roomVer := gomatrixserverlib.RoomVersionV1 |
| 81 | body := request.Content() |
| 82 | event, err := gomatrixserverlib.NewEventFromTrustedJSON(body, false, roomVer) |
| 83 | switch err.(type) { |
| 84 | case gomatrixserverlib.BadJSONError: |
| 85 | return util.JSONResponse{ |
| 86 | Code: http.StatusBadRequest, |
| 87 | JSON: jsonerror.BadJSON(err.Error()), |
| 88 | } |
| 89 | case nil: |
| 90 | default: |
| 91 | return util.JSONResponse{ |
| 92 | Code: http.StatusBadRequest, |
| 93 | JSON: jsonerror.NotJSON("The request body could not be decoded into an invite v1 request. " + err.Error()), |
| 94 | } |
| 95 | } |
| 96 | var strippedState []gomatrixserverlib.InviteV2StrippedState |
| 97 | if err := json.Unmarshal(event.Unsigned(), &strippedState); err != nil { |
| 98 | // just warn, they may not have added any. |
| 99 | util.GetLogger(httpReq.Context()).Warnf("failed to extract stripped state from invite event") |
| 100 | } |
| 101 | return processInvite( |
| 102 | httpReq.Context(), false, event, roomVer, strippedState, roomID, eventID, cfg, rsAPI, keys, |
| 103 | ) |
| 104 | } |
| 105 | |
| 106 | func processInvite( |
| 107 | ctx context.Context, |
no test coverage detected