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

Function InviteV2

federationapi/routing/invite.go:32–68  ·  view source on GitHub ↗

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,
)

Source from the content-addressed store, hash-verified

30
31// InviteV2 implements /_matrix/federation/v2/invite/{roomID}/{eventID}
32func 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}
71func InviteV1(

Callers 1

SetupFunction · 0.85

Calls 4

processInviteFunction · 0.85
ContextMethod · 0.80
RoomVersionMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected