mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-07-30 04:52:46 +00:00
parent
8c721b555e
commit
94ea325c93
6 changed files with 135 additions and 14 deletions
|
@ -164,13 +164,36 @@ func SetLocalAlias(
|
|||
}
|
||||
|
||||
// RemoveLocalAlias implements DELETE /directory/room/{roomAlias}
|
||||
// TODO: Check if the user has the power level to remove an alias
|
||||
func RemoveLocalAlias(
|
||||
req *http.Request,
|
||||
device *authtypes.Device,
|
||||
alias string,
|
||||
aliasAPI roomserverAPI.RoomserverAliasAPI,
|
||||
) util.JSONResponse {
|
||||
|
||||
creatorQueryReq := roomserverAPI.GetCreatorIDForAliasRequest{
|
||||
Alias: alias,
|
||||
}
|
||||
var creatorQueryRes roomserverAPI.GetCreatorIDForAliasResponse
|
||||
if err := aliasAPI.GetCreatorIDForAlias(req.Context(), &creatorQueryReq, &creatorQueryRes); err != nil {
|
||||
return httputil.LogThenError(req, err)
|
||||
}
|
||||
|
||||
if creatorQueryRes.UserID == "" {
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusNotFound,
|
||||
JSON: jsonerror.NotFound("Alias does not exist"),
|
||||
}
|
||||
}
|
||||
|
||||
if creatorQueryRes.UserID != device.UserID {
|
||||
// TODO: Still allow deletion if user is admin
|
||||
return util.JSONResponse{
|
||||
Code: http.StatusForbidden,
|
||||
JSON: jsonerror.Forbidden("You do not have permission to delete this alias"),
|
||||
}
|
||||
}
|
||||
|
||||
queryReq := roomserverAPI.RemoveRoomAliasRequest{
|
||||
Alias: alias,
|
||||
UserID: device.UserID,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue