GetAvatarURL implements GET /profile/{userID}/avatar_url
( req *http.Request, profileAPI userapi.ClientUserAPI, cfg *config.ClientAPI, userID string, asAPI appserviceAPI.AppServiceInternalAPI, federation *gomatrixserverlib.FederationClient, )
| 285 | |
| 286 | // GetAvatarURL implements GET /profile/{userID}/avatar_url |
| 287 | func GetAvatarURL( |
| 288 | req *http.Request, profileAPI userapi.ClientUserAPI, cfg *config.ClientAPI, |
| 289 | userID string, asAPI appserviceAPI.AppServiceInternalAPI, |
| 290 | federation *gomatrixserverlib.FederationClient, |
| 291 | ) util.JSONResponse { |
| 292 | profile, err := getProfile(req.Context(), profileAPI, cfg, userID, asAPI, federation) |
| 293 | if err != nil { |
| 294 | if err == eventutil.ErrProfileNoExists { |
| 295 | return util.JSONResponse{ |
| 296 | Code: http.StatusNotFound, |
| 297 | JSON: jsonerror.NotFound("The user does not exist or does not have a profile"), |
| 298 | } |
| 299 | } |
| 300 | |
| 301 | util.GetLogger(req.Context()).WithError(err).Error("getProfile failed") |
| 302 | return jsonerror.InternalServerError() |
| 303 | } |
| 304 | |
| 305 | return util.JSONResponse{ |
| 306 | Code: http.StatusOK, |
| 307 | JSON: eventutil.AvatarURL{ |
| 308 | AvatarURL: profile.AvatarURL, |
| 309 | }, |
| 310 | } |
| 311 | } |
| 312 | |
| 313 | // SetAvatarURL implements PUT /profile/{userID}/avatar_url |
| 314 | func SetAvatarURL( |
no test coverage detected