@@ -1155,18 +1155,7 @@ func (m *membershipAllower) membershipAllowedSelf() error { // nolint: gocyclo
11551155
11561156 switch m .newMember .Membership {
11571157 case spec .Knock :
1158- if m .joinRule .JoinRule != spec .Knock && m .joinRule .JoinRule != spec .KnockRestricted {
1159- return m .membershipFailed (
1160- "join rule %q does not allow knocking" , m .joinRule .JoinRule ,
1161- )
1162- }
1163- // A user that is not in the room is allowed to knock if the join
1164- // rules are "knock" and they are not already joined to, invited to
1165- // or banned from the room.
1166- // Spec: https://spec.matrix.org/unstable/rooms/v7/
1167- // MSC3787 extends this: the behaviour above is also permitted if the
1168- // join rules are "knock_restricted"
1169- // Spec: https://github.com/matrix-org/matrix-spec-proposals/pull/3787
1158+ // Check if the given roomVersionImpl allows knocking.
11701159 return m .roomVersionImpl .CheckKnockingAllowed (m )
11711160 case spec .Join :
11721161 if m .joinRule .JoinRule == spec .Restricted || m .joinRule .JoinRule == spec .KnockRestricted {
@@ -1244,8 +1233,16 @@ func disallowKnocking(m *membershipAllower) error {
12441233 )
12451234}
12461235
1236+ // A user that is not in the room is allowed to knock if the join
1237+ // rules are "knock" and they are not already joined to
1238+ // or banned from the room.
1239+ // Spec: https://spec.matrix.org/unstable/rooms/v7/
1240+ // MSC3787 extends this: the behaviour above is also permitted if the
1241+ // join rules are "knock_restricted"
1242+ // Spec: https://github.com/matrix-org/matrix-spec-proposals/pull/3787
12471243func checkKnocking (m * membershipAllower ) error {
1248- supported := m .joinRule .JoinRule == spec .Knock || m .joinRule .JoinRule == spec .Restricted || m .joinRule .JoinRule == spec .KnockRestricted
1244+ // If the join_rule is anything other than knock or knock_restricted, reject.
1245+ supported := m .joinRule .JoinRule == spec .Knock || m .joinRule .JoinRule == spec .KnockRestricted
12491246 if ! supported {
12501247 return m .membershipFailed (
12511248 "room version %q does not support knocking on rooms with join rule %q" ,
0 commit comments