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

Function loadProfile

clientapi/routing/membership.go:331–351  ·  view source on GitHub ↗

loadProfile lookups the profile of a given user from the database and returns it if the user is local to this server, or returns an empty profile if not. Returns an error if the retrieval failed or if the first parameter isn't a valid Matrix ID.

(
	ctx context.Context,
	userID string,
	cfg *config.ClientAPI,
	profileAPI userapi.ClientUserAPI,
	asAPI appserviceAPI.AppServiceInternalAPI,
)

Source from the content-addressed store, hash-verified

329// Returns an error if the retrieval failed or if the first parameter isn't a
330// valid Matrix ID.
331func loadProfile(
332 ctx context.Context,
333 userID string,
334 cfg *config.ClientAPI,
335 profileAPI userapi.ClientUserAPI,
336 asAPI appserviceAPI.AppServiceInternalAPI,
337) (*authtypes.Profile, error) {
338 _, serverName, err := gomatrixserverlib.SplitID('@', userID)
339 if err != nil {
340 return nil, err
341 }
342
343 var profile *authtypes.Profile
344 if serverName == cfg.Matrix.ServerName {
345 profile, err = appserviceAPI.RetrieveUserProfile(ctx, userID, asAPI, profileAPI)
346 } else {
347 profile = &authtypes.Profile{}
348 }
349
350 return profile, err
351}
352
353func extractRequestData(req *http.Request, roomID string, rsAPI roomserverAPI.ClientRoomserverAPI) (
354 body *threepid.MembershipRequest, evTime time.Time, roomVer gomatrixserverlib.RoomVersion, resErr *util.JSONResponse,

Callers 3

buildMembershipEventFunction · 0.85
SendInviteAsRoomOwnerFunction · 0.85
SendLeaveAsRoomOwnerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected