mirror of
https://github.com/element-hq/dendrite.git
synced 2025-09-13 21:02:25 +03:00
mas: modify PUT /profile/{userID}/displayname endpoint
Extended logic of the endpoint in order to make it compatible with MAS
This commit is contained in:
parent
524f65cb0c
commit
ff63e7fa98
2 changed files with 50 additions and 36 deletions
|
@ -760,42 +760,38 @@ func AdminRetrieveAccount(req *http.Request, cfg *config.ClientAPI, userAPI user
|
|||
Deactivated bool `json:"deactivated"`
|
||||
}{}
|
||||
|
||||
{
|
||||
var rs api.QueryAccountByLocalpartResponse
|
||||
err := userAPI.QueryAccountByLocalpart(req.Context(), &api.QueryAccountByLocalpartRequest{Localpart: local, ServerName: domain}, &rs)
|
||||
if err == sql.ErrNoRows {
|
||||
var rs api.QueryAccountByLocalpartResponse
|
||||
err = userAPI.QueryAccountByLocalpart(req.Context(), &api.QueryAccountByLocalpartRequest{Localpart: local, ServerName: domain}, &rs)
|
||||
if err == sql.ErrNoRows {
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusNotFound,
|
||||
JSON: spec.NotFound(fmt.Sprintf("User '%s' not found", userID)),
|
||||
}
|
||||
} else if err != nil {
|
||||
logger.WithError(err).Error("userAPI.QueryAccountByLocalpart")
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusInternalServerError,
|
||||
JSON: spec.Unknown(err.Error()),
|
||||
}
|
||||
}
|
||||
body.Deactivated = rs.Account.Deactivated
|
||||
|
||||
profile, err := userAPI.QueryProfile(req.Context(), userID)
|
||||
if err != nil {
|
||||
if err == appserviceAPI.ErrProfileNotExists {
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusNotFound,
|
||||
JSON: spec.NotFound(fmt.Sprintf("User '%s' not found", userID)),
|
||||
JSON: spec.NotFound(err.Error()),
|
||||
}
|
||||
} else if err != nil {
|
||||
logger.WithError(err).Error("userAPI.QueryAccountByLocalpart")
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusInternalServerError,
|
||||
JSON: spec.Unknown(err.Error()),
|
||||
}
|
||||
}
|
||||
body.Deactivated = rs.Account.Deactivated
|
||||
}
|
||||
|
||||
{
|
||||
profile, err := userAPI.QueryProfile(req.Context(), userID)
|
||||
if err != nil {
|
||||
if err == appserviceAPI.ErrProfileNotExists {
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusNotFound,
|
||||
JSON: spec.NotFound(err.Error()),
|
||||
}
|
||||
} else if err != nil {
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusInternalServerError,
|
||||
JSON: spec.Unknown(err.Error()),
|
||||
}
|
||||
}
|
||||
}
|
||||
body.AvatarURL = profile.AvatarURL
|
||||
body.DisplayName = profile.DisplayName
|
||||
}
|
||||
body.AvatarURL = profile.AvatarURL
|
||||
body.DisplayName = profile.DisplayName
|
||||
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusOK,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue