mirror of
https://github.com/hoernschen/dendrite.git
synced 2024-12-27 07:28:27 +00:00
Fix return codes
This commit is contained in:
parent
e1c61122e7
commit
f4ad4db6fb
1 changed files with 6 additions and 4 deletions
|
@ -222,13 +222,13 @@ func attemptMakeJoinForRestrictedMembership(
|
||||||
if powerLevelsEvent, err := provider.PowerLevels(); err != nil {
|
if powerLevelsEvent, err := provider.PowerLevels(); err != nil {
|
||||||
logger.WithError(err).Error("Failed to get power levels from auth events")
|
logger.WithError(err).Error("Failed to get power levels from auth events")
|
||||||
return util.JSONResponse{
|
return util.JSONResponse{
|
||||||
Code: http.StatusForbidden, // TODO: StatusBadRequest
|
Code: http.StatusBadRequest,
|
||||||
JSON: jsonerror.UnableToAuthoriseJoin("Room power levels do not exist"),
|
JSON: jsonerror.UnableToAuthoriseJoin("Room power levels do not exist"),
|
||||||
}
|
}
|
||||||
} else if err := json.Unmarshal(powerLevelsEvent.Content(), &powerLevels); err != nil {
|
} else if err := json.Unmarshal(powerLevelsEvent.Content(), &powerLevels); err != nil {
|
||||||
logger.WithError(err).Error("Failed to unmarshal power levels")
|
logger.WithError(err).Error("Failed to unmarshal power levels")
|
||||||
return util.JSONResponse{
|
return util.JSONResponse{
|
||||||
Code: http.StatusForbidden, // TODO: StatusBadRequest
|
Code: http.StatusBadRequest,
|
||||||
JSON: jsonerror.UnableToAuthoriseJoin("Failed to unmarshal room power levels"),
|
JSON: jsonerror.UnableToAuthoriseJoin("Failed to unmarshal room power levels"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -294,6 +294,8 @@ func attemptMakeJoinForRestrictedMembership(
|
||||||
// If the user has the ability to invite to the room then they are a
|
// If the user has the ability to invite to the room then they are a
|
||||||
// suitable candidate for the `join_authorised_via_users_server`.
|
// suitable candidate for the `join_authorised_via_users_server`.
|
||||||
if powerLevels.UserLevel(*member.StateKey) >= powerLevels.Invite {
|
if powerLevels.UserLevel(*member.StateKey) >= powerLevels.Invite {
|
||||||
|
// Now
|
||||||
|
|
||||||
// We'll set the event content again, this time including the
|
// We'll set the event content again, this time including the
|
||||||
// `join_authorised_via_users_server` field for the chosen user.
|
// `join_authorised_via_users_server` field for the chosen user.
|
||||||
err := builder.SetContent(map[string]interface{}{
|
err := builder.SetContent(map[string]interface{}{
|
||||||
|
@ -339,7 +341,7 @@ func attemptMakeJoinForRestrictedMembership(
|
||||||
// users had a suitable power level to invite other users, so we
|
// users had a suitable power level to invite other users, so we
|
||||||
// don't have the ability to grant joins.
|
// don't have the ability to grant joins.
|
||||||
return util.JSONResponse{
|
return util.JSONResponse{
|
||||||
Code: http.StatusForbidden, // TODO: StatusBadRequest
|
Code: http.StatusBadRequest,
|
||||||
JSON: jsonerror.UnableToGrantJoin("None of the users from this homeserver have the power to invite"),
|
JSON: jsonerror.UnableToGrantJoin("None of the users from this homeserver have the power to invite"),
|
||||||
}
|
}
|
||||||
case ableToAuthoriseJoin && !foundUserInAnyRoom:
|
case ableToAuthoriseJoin && !foundUserInAnyRoom:
|
||||||
|
@ -353,7 +355,7 @@ func attemptMakeJoinForRestrictedMembership(
|
||||||
// We don't seem to be joined to any of the allowed rooms, so we
|
// We don't seem to be joined to any of the allowed rooms, so we
|
||||||
// can't even check if the join is supposed to be allowed or not.
|
// can't even check if the join is supposed to be allowed or not.
|
||||||
return util.JSONResponse{
|
return util.JSONResponse{
|
||||||
Code: http.StatusForbidden, // TODO: StatusBadRequest
|
Code: http.StatusBadRequest,
|
||||||
JSON: jsonerror.UnableToAuthoriseJoin("This homeserver isn't joined to any of the allowed rooms"),
|
JSON: jsonerror.UnableToAuthoriseJoin("This homeserver isn't joined to any of the allowed rooms"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue