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

Function checkAndProcessThreepid

clientapi/routing/membership.go:383–425  ·  view source on GitHub ↗
(
	req *http.Request,
	device *userapi.Device,
	body *threepid.MembershipRequest,
	cfg *config.ClientAPI,
	rsAPI roomserverAPI.ClientRoomserverAPI,
	profileAPI userapi.ClientUserAPI,
	roomID string,
	evTime time.Time,
)

Source from the content-addressed store, hash-verified

381}
382
383func checkAndProcessThreepid(
384 req *http.Request,
385 device *userapi.Device,
386 body *threepid.MembershipRequest,
387 cfg *config.ClientAPI,
388 rsAPI roomserverAPI.ClientRoomserverAPI,
389 profileAPI userapi.ClientUserAPI,
390 roomID string,
391 evTime time.Time,
392) (inviteStored bool, errRes *util.JSONResponse) {
393
394 inviteStored, err := threepid.CheckAndProcessInvite(
395 req.Context(), device, body, cfg, rsAPI, profileAPI,
396 roomID, evTime,
397 )
398 if err == threepid.ErrMissingParameter {
399 return inviteStored, &util.JSONResponse{
400 Code: http.StatusBadRequest,
401 JSON: jsonerror.BadJSON(err.Error()),
402 }
403 } else if err == threepid.ErrNotTrusted {
404 return inviteStored, &util.JSONResponse{
405 Code: http.StatusBadRequest,
406 JSON: jsonerror.NotTrusted(body.IDServer),
407 }
408 } else if err == eventutil.ErrRoomNoExists {
409 return inviteStored, &util.JSONResponse{
410 Code: http.StatusNotFound,
411 JSON: jsonerror.NotFound(err.Error()),
412 }
413 } else if e, ok := err.(gomatrixserverlib.BadJSONError); ok {
414 return inviteStored, &util.JSONResponse{
415 Code: http.StatusBadRequest,
416 JSON: jsonerror.BadJSON(e.Error()),
417 }
418 }
419 if err != nil {
420 util.GetLogger(req.Context()).WithError(err).Error("threepid.CheckAndProcessInvite failed")
421 er := jsonerror.InternalServerError()
422 return inviteStored, &er
423 }
424 return
425}
426
427func checkMemberInRoom(ctx context.Context, rsAPI roomserverAPI.ClientRoomserverAPI, userID, roomID string) *util.JSONResponse {
428 tuple := gomatrixserverlib.StateKeyTuple{

Callers 1

SendInviteFunction · 0.85

Calls 2

ContextMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected