state-res: Reduce indentation by adding early returns
This commit is contained in:
parent
ee977b48f0
commit
1bdeebbd00
@ -902,9 +902,13 @@ fn verify_third_party_invite(
|
||||
return false;
|
||||
}
|
||||
|
||||
// If there is no m.room.third_party_invite event in the current room state
|
||||
// with state_key matching token, reject
|
||||
if let Some(current_tpid) = current_third_party_invite {
|
||||
// If there is no m.room.third_party_invite event in the current room state with state_key
|
||||
// matching token, reject
|
||||
let current_tpid = match current_third_party_invite {
|
||||
Some(id) => id,
|
||||
None => return false,
|
||||
};
|
||||
|
||||
if current_tpid.state_key() != Some(&tp_id.signed.token) {
|
||||
return false;
|
||||
}
|
||||
@ -915,23 +919,21 @@ fn verify_third_party_invite(
|
||||
|
||||
// If any signature in signed matches any public key in the m.room.third_party_invite event,
|
||||
// allow
|
||||
if let Ok(tpid_ev) =
|
||||
from_json_str::<RoomThirdPartyInviteEventContent>(current_tpid.content().get())
|
||||
{
|
||||
let tpid_ev =
|
||||
match from_json_str::<RoomThirdPartyInviteEventContent>(current_tpid.content().get()) {
|
||||
Ok(ev) => ev,
|
||||
Err(_) => return false,
|
||||
};
|
||||
|
||||
// A list of public keys in the public_keys field
|
||||
for key in tpid_ev.public_keys.unwrap_or_default() {
|
||||
if key.public_key == tp_id.signed.token {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// A single public key in the public_key field
|
||||
tpid_ev.public_key == tp_id.signed.token
|
||||
} else {
|
||||
false
|
||||
}
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
Loading…
x
Reference in New Issue
Block a user