Update error codes

This commit is contained in:
Neil Alexander 2021-11-11 13:44:22 +00:00
parent 43727e978d
commit 3300effe39
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944

View file

@ -249,19 +249,11 @@ func (r *Joiner) performJoinRoomByID(
Msg: rerr.Error(), Msg: rerr.Error(),
} }
} else if restricted { } else if restricted {
found := false
for _, roomID := range roomIDs { for _, roomID := range roomIDs {
if err = r.attemptRestrictedJoinUsingRoomID(ctx, req, roomID, &eb); err == nil { if err = r.attemptRestrictedJoinUsingRoomID(ctx, req, roomID, &eb); err == nil {
found = true
break break
} }
} }
if !found {
return "", "", &rsAPI.PerformError{
Code: rsAPI.PerformErrorNotAllowed,
Msg: "You do not have permission to join this restricted room.",
}
}
} }
// Try to construct an actual join event from the template. // Try to construct an actual join event from the template.
@ -305,7 +297,7 @@ func (r *Joiner) performJoinRoomByID(
if err = inputRes.Err(); err != nil { if err = inputRes.Err(); err != nil {
return "", "", &rsAPI.PerformError{ return "", "", &rsAPI.PerformError{
Code: rsAPI.PerformErrorNotAllowed, Code: rsAPI.PerformErrorNotAllowed,
Msg: fmt.Sprintf("InputRoomEvents auth failed: %s", err), Msg: fmt.Sprintf("Failed to join the room %q: %s", req.RoomIDOrAlias, err),
} }
} }
} }
@ -321,7 +313,7 @@ func (r *Joiner) performJoinRoomByID(
if len(req.ServerNames) == 0 { if len(req.ServerNames) == 0 {
return "", "", &rsAPI.PerformError{ return "", "", &rsAPI.PerformError{
Code: rsAPI.PerformErrorNoRoom, Code: rsAPI.PerformErrorNoRoom,
Msg: fmt.Sprintf("room ID %q does not exist", req.RoomIDOrAlias), Msg: fmt.Sprintf("Room ID %q does not exist!", req.RoomIDOrAlias),
} }
} }
} }
@ -332,7 +324,10 @@ func (r *Joiner) performJoinRoomByID(
default: default:
// Something else went wrong. // Something else went wrong.
return "", "", fmt.Errorf("error joining local room: %q", err) return "", "", &rsAPI.PerformError{
Code: rsAPI.PerformErrorNotAllowed,
Msg: fmt.Sprintf("Failed to join the room %q: %s", req.RoomIDOrAlias, err),
}
} }
// By this point, if req.RoomIDOrAlias contained an alias, then // By this point, if req.RoomIDOrAlias contained an alias, then