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

Function InviteV1

federationapi/routing/invite.go:71–104  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

69
70// InviteV1 implements /_matrix/federation/v1/invite/{roomID}/{eventID}
71func 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
106func processInvite(
107 ctx context.Context,

Callers 1

SetupFunction · 0.85

Calls 3

processInviteFunction · 0.85
ContextMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected