Skip to content
This repository has been archived by the owner on Nov 25, 2024. It is now read-only.

Commit

Permalink
Add and use M_ROOM_IN_USE
Browse files Browse the repository at this point in the history
Signed-off-by: nivekuil <[email protected]>
  • Loading branch information
nivekuil committed Aug 12, 2021
1 parent 125ea75 commit e125942
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
6 changes: 6 additions & 0 deletions clientapi/jsonerror/jsonerror.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 7 additions & 3 deletions clientapi/routing/createroom.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -483,8 +486,9 @@ func createRoom(
return jsonerror.InternalServerError()
}

if aliasResp.AliasExists {
return util.MessageResponse(400, "Alias already exists")
return util.JSONResponse{
Code: http.StatusBadRequest,
JSON: jsonerror.RoomInUse("Room alias already exists."),
}
}

Expand Down

0 comments on commit e125942

Please sign in to comment.