state-res: Allow invite->knock membership transition

According to spec clarification
This commit is contained in:
Kévin Commaille 2022-09-30 14:28:53 +02:00 committed by Kévin Commaille
parent 2bdbf49535
commit 279c9d0fa6
2 changed files with 7 additions and 6 deletions

View File

@ -5,6 +5,9 @@ Bug fixes:
* Fix third party invite event authorization. The event was not allowed even * Fix third party invite event authorization. The event was not allowed even
after passing all the required checks, so it could fail further down the after passing all the required checks, so it could fail further down the
algorithm. algorithm.
* Allow `invite` -> `knock` membership transition
* The spec was determined to be wrong about rejecting it:
<https://github.com/matrix-org/matrix-spec/pull/1175>
# 0.8.0 # 0.8.0

View File

@ -676,7 +676,7 @@ fn valid_membership_change(
false false
} else { } else {
// 2. If `sender` does not match `state_key`, reject. // 2. If `sender` does not match `state_key`, reject.
// 3. If the `sender`'s current membership is not `ban`, `invite`, or `join`, allow. // 3. If the `sender`'s current membership is not `ban` or `join`, allow.
// 4. Otherwise, reject. // 4. Otherwise, reject.
if sender != target_user { if sender != target_user {
warn!( warn!(
@ -685,13 +685,11 @@ fn valid_membership_change(
"Can't make another user join, sender did not match target" "Can't make another user join, sender did not match target"
); );
false false
} else if matches!( } else if matches!(sender_membership, MembershipState::Ban | MembershipState::Join)
sender_membership, {
MembershipState::Ban | MembershipState::Invite | MembershipState::Join
) {
warn!( warn!(
?target_user_membership_event_id, ?target_user_membership_event_id,
"Membership state of ban, invite, or join are invalid", "Membership state of ban or join are invalid",
); );
false false
} else { } else {