GetDisplayName implements GET /profile/{userID}/displayname
( req *http.Request, profileAPI userapi.ClientUserAPI, cfg *config.ClientAPI, userID string, asAPI appserviceAPI.AppServiceInternalAPI, federation *gomatrixserverlib.FederationClient, )
| 414 | |
| 415 | // GetDisplayName implements GET /profile/{userID}/displayname |
| 416 | func 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 |
| 443 | func SetDisplayName( |
no test coverage detected