mirror of
https://github.com/1f349/dendrite.git
synced 2024-11-22 11:41:38 +00:00
Fix failing complement test (#1917)
Specifically `TestBannedUserCannotSendJoin`
This commit is contained in:
parent
f8ae391a5b
commit
7df3e691f2
@ -271,17 +271,27 @@ func SendJoin(
|
|||||||
|
|
||||||
// Check if the user is already in the room. If they're already in then
|
// Check if the user is already in the room. If they're already in then
|
||||||
// there isn't much point in sending another join event into the room.
|
// there isn't much point in sending another join event into the room.
|
||||||
|
// Also check to see if they are banned: if they are then we reject them.
|
||||||
alreadyJoined := false
|
alreadyJoined := false
|
||||||
|
isBanned := false
|
||||||
for _, se := range stateAndAuthChainResponse.StateEvents {
|
for _, se := range stateAndAuthChainResponse.StateEvents {
|
||||||
if !se.StateKeyEquals(*event.StateKey()) {
|
if !se.StateKeyEquals(*event.StateKey()) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if membership, merr := se.Membership(); merr == nil {
|
if membership, merr := se.Membership(); merr == nil {
|
||||||
alreadyJoined = (membership == gomatrixserverlib.Join)
|
alreadyJoined = (membership == gomatrixserverlib.Join)
|
||||||
|
isBanned = (membership == gomatrixserverlib.Ban)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if isBanned {
|
||||||
|
return util.JSONResponse{
|
||||||
|
Code: http.StatusForbidden,
|
||||||
|
JSON: jsonerror.Forbidden("user is banned"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Send the events to the room server.
|
// Send the events to the room server.
|
||||||
// We are responsible for notifying other servers that the user has joined
|
// We are responsible for notifying other servers that the user has joined
|
||||||
// the room, so set SendAsServer to cfg.Matrix.ServerName
|
// the room, so set SendAsServer to cfg.Matrix.ServerName
|
||||||
|
Loading…
Reference in New Issue
Block a user