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

Function SendInvite

clientapi/routing/membership.go:208–238  ·  view source on GitHub ↗
(
	req *http.Request, profileAPI userapi.ClientUserAPI, device *userapi.Device,
	roomID string, cfg *config.ClientAPI,
	rsAPI roomserverAPI.ClientRoomserverAPI, asAPI appserviceAPI.AppServiceInternalAPI,
)

Source from the content-addressed store, hash-verified

206}
207
208func SendInvite(
209 req *http.Request, profileAPI userapi.ClientUserAPI, device *userapi.Device,
210 roomID string, cfg *config.ClientAPI,
211 rsAPI roomserverAPI.ClientRoomserverAPI, asAPI appserviceAPI.AppServiceInternalAPI,
212) util.JSONResponse {
213 body, evTime, _, reqErr := extractRequestData(req, roomID, rsAPI)
214 if reqErr != nil {
215 return *reqErr
216 }
217
218 inviteStored, jsonErrResp := checkAndProcessThreepid(
219 req, device, body, cfg, rsAPI, profileAPI, roomID, evTime,
220 )
221 if jsonErrResp != nil {
222 return *jsonErrResp
223 }
224
225 // If an invite has been stored on an identity server, it means that a
226 // m.room.third_party_invite event has been emitted and that we shouldn't
227 // emit a m.room.member one.
228 if inviteStored {
229 return util.JSONResponse{
230 Code: http.StatusOK,
231 JSON: struct{}{},
232 }
233 }
234
235 // We already received the return value, so no need to check for an error here.
236 response, _ := sendInvite(req.Context(), profileAPI, device, roomID, body.UserID, body.Reason, cfg, rsAPI, asAPI, evTime)
237 return response
238}
239
240// sendInvite sends an invitation to a user. Returns a JSONResponse and an error
241func sendInvite(

Callers 1

SetupFunction · 0.85

Calls 4

extractRequestDataFunction · 0.85
checkAndProcessThreepidFunction · 0.85
sendInviteFunction · 0.85
ContextMethod · 0.80

Tested by

no test coverage detected