Add and use M_ROOM_IN_USE

Signed-off-by: nivekuil <mail@nivekuil.com>
This commit is contained in:
nivekuil 2021-08-11 21:16:51 -07:00
parent 125ea75b24
commit 1ac94cdacd
2 changed files with 14 additions and 2 deletions

View file

@ -111,6 +111,12 @@ func UserInUse(msg string) *MatrixError {
return &MatrixError{"M_USER_IN_USE", msg}
}
// RoomInUse is an error returned when the client tries to make a room
// that already exists
func RoomInUse(msg string) *MatrixError {
return &MatrixError{"M_ROOM_IN_USE", msg}
}
// ASExclusive is an error returned when an application service tries to
// register an username that is outside of its registered namespace, or if a
// user attempts to register a username or room alias within an exclusive

View file

@ -325,7 +325,10 @@ func createRoom(
return jsonerror.InternalServerError()
}
if aliasResp.RoomID != "" {
return util.MessageResponse(400, "Alias already exists")
return util.JSONResponse{
Code: http.StatusBadRequest,
JSON: jsonerror.RoomInUse("Room ID already exists."),
}
}
aliasEvent = &fledglingEvent{
@ -484,7 +487,10 @@ func createRoom(
}
if aliasResp.AliasExists {
return util.MessageResponse(400, "Alias already exists")
return util.JSONResponse{
Code: http.StatusBadRequest,
JSON: jsonerror.RoomInUse("Room alias already exists."),
}
}
}