Skip to content

Commit

Permalink
Fix thinko
Browse files Browse the repository at this point in the history
  • Loading branch information
S7evinK committed Jan 15, 2024
1 parent e0911c0 commit 2e1e54a
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions eventauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -1172,10 +1172,11 @@ func (m *membershipAllower) membershipAllowedSelf() error { // nolint: gocyclo
if err := m.membershipAllowedSelfForRestrictedJoin(); err != nil {
return err
}
}
// If, after validating restricted joins, the room is now "public", allow.
if m.joinRule.JoinRule == spec.Public {
return nil
// If, after validating restricted joins, the room is now "public", allow.
// This means that transitions from knock|invite|leave to join are allowed.
if m.joinRule.JoinRule == spec.Public {
return nil
}
}
// An invited user is always allowed to join, regardless of the join rule
if m.oldMember.Membership == spec.Invite {
Expand All @@ -1185,6 +1186,13 @@ func (m *membershipAllower) membershipAllowedSelf() error { // nolint: gocyclo
if m.oldMember.Membership == spec.Join {
return nil
}

// A user that is not in the room is allowed to join if the room
// join rules are "public".
if m.oldMember.Membership == spec.Leave && m.joinRule.JoinRule == spec.Public {
return nil
}

return m.membershipFailed(
"join rule %q forbids it", m.joinRule.JoinRule,
)
Expand Down

0 comments on commit 2e1e54a

Please sign in to comment.