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

Function GetDisplayName

clientapi/routing/profile.go:416–440  ·  view source on GitHub ↗

GetDisplayName implements GET /profile/{userID}/displayname

(
	req *http.Request, profileAPI userapi.ClientUserAPI, cfg *config.ClientAPI,
	userID string, asAPI appserviceAPI.AppServiceInternalAPI,
	federation *gomatrixserverlib.FederationClient,
)

Source from the content-addressed store, hash-verified

414
415// GetDisplayName implements GET /profile/{userID}/displayname
416func GetDisplayName(
417 req *http.Request, profileAPI userapi.ClientUserAPI, cfg *config.ClientAPI,
418 userID string, asAPI appserviceAPI.AppServiceInternalAPI,
419 federation *gomatrixserverlib.FederationClient,
420) util.JSONResponse {
421 profile, err := getProfile(req.Context(), profileAPI, cfg, userID, asAPI, federation)
422 if err != nil {
423 if err == eventutil.ErrProfileNoExists {
424 return util.JSONResponse{
425 Code: http.StatusNotFound,
426 JSON: jsonerror.NotFound("The user does not exist or does not have a profile"),
427 }
428 }
429
430 util.GetLogger(req.Context()).WithError(err).Error("getProfile failed")
431 return jsonerror.InternalServerError()
432 }
433
434 return util.JSONResponse{
435 Code: http.StatusOK,
436 JSON: eventutil.DisplayName{
437 DisplayName: profile.DisplayName,
438 },
439 }
440}
441
442// SetDisplayName implements PUT /profile/{userID}/displayname
443func SetDisplayName(

Callers 1

SetupFunction · 0.85

Calls 3

getProfileFunction · 0.85
ContextMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected