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

Function GetAvatarURL

clientapi/routing/profile.go:287–311  ·  view source on GitHub ↗

GetAvatarURL implements GET /profile/{userID}/avatar_url

(
	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

285
286// GetAvatarURL implements GET /profile/{userID}/avatar_url
287func 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
314func SetAvatarURL(

Callers 1

SetupFunction · 0.85

Calls 3

getProfileFunction · 0.85
ContextMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected