mirror of
https://github.com/element-hq/dendrite.git
synced 2025-09-13 21:02:25 +03:00
mas: added username_available endpoint
This commit is contained in:
parent
ba542fedcd
commit
2c47959600
4 changed files with 60 additions and 2 deletions
|
@ -496,6 +496,27 @@ func AdminDownloadState(req *http.Request, device *api.Device, rsAPI roomserverA
|
|||
}
|
||||
}
|
||||
|
||||
func AdminCheckUsernameAvailable(
|
||||
req *http.Request,
|
||||
userAPI userapi.ClientUserAPI,
|
||||
cfg *config.ClientAPI,
|
||||
) util.JSONResponse {
|
||||
username := req.URL.Query().Get("username")
|
||||
if username == "" {
|
||||
return util.MessageResponse(http.StatusBadRequest, "Query parameter 'username' is missing or empty")
|
||||
}
|
||||
rq := userapi.QueryAccountAvailabilityRequest{Localpart: username, ServerName: cfg.Matrix.ServerName}
|
||||
rs := userapi.QueryAccountAvailabilityResponse{}
|
||||
if err := userAPI.QueryAccountAvailability(req.Context(), &rq, &rs); err != nil {
|
||||
return util.ErrorResponse(err)
|
||||
}
|
||||
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusOK,
|
||||
JSON: map[string]bool{"available": rs.Available},
|
||||
}
|
||||
}
|
||||
|
||||
// GetEventReports returns reported events for a given user/room.
|
||||
func GetEventReports(
|
||||
req *http.Request,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue