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

Fix failing complement test #1917

Merged
merged 1 commit into from
Jul 13, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions federationapi/routing/join.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,17 +271,27 @@ func SendJoin(

// 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.
// Also check to see if they are banned: if they are then we reject them.
alreadyJoined := false
isBanned := false
for _, se := range stateAndAuthChainResponse.StateEvents {
if !se.StateKeyEquals(*event.StateKey()) {
continue
}
if membership, merr := se.Membership(); merr == nil {
alreadyJoined = (membership == gomatrixserverlib.Join)
isBanned = (membership == gomatrixserverlib.Ban)
break
}
}

if isBanned {
return util.JSONResponse{
Code: http.StatusForbidden,
JSON: jsonerror.Forbidden("user is banned"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is a message that will get passed through to clients then we might want to make it friendlier.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Friendlier how? I'm saying they are banned. Also, this requires explicit fudginess for it to work (you need to make_join with an unbanned user, then swap the state_key over to a banned user), so I don't expect this to happen in normal operation.

}
}

// Send the events to the room server.
// We are responsible for notifying other servers that the user has joined
// the room, so set SendAsServer to cfg.Matrix.ServerName
Expand Down