events: make allow field for restricted rooms optional
In the spec, it doesn't state that it is a required field, even for restricted rooms
This commit is contained in:
parent
f17de39ed4
commit
c37843e9be
@ -6,6 +6,7 @@ Bug fixes:
|
||||
fragment.
|
||||
- Fix serialization of `room::message::Relation` and `room::encrypted::Relation`
|
||||
which could cause duplicate `rel_type` keys.
|
||||
- `Restricted` no longer fails to deserialize when the `allow` field is missing
|
||||
|
||||
Improvements:
|
||||
|
||||
|
@ -168,6 +168,7 @@ impl From<JoinRule> for SpaceRoomJoinRule {
|
||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||
pub struct Restricted {
|
||||
/// Allow rules which describe conditions that allow joining a room.
|
||||
#[serde(default)]
|
||||
pub allow: Vec<AllowRule>,
|
||||
}
|
||||
|
||||
@ -324,6 +325,16 @@ mod tests {
|
||||
assert_eq!(serde_json::to_string(&allow_rule).unwrap(), json);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn restricted_room_no_allow_field() {
|
||||
let json = r#"{"join_rule":"restricted"}"#;
|
||||
let join_rules: RoomJoinRulesEventContent = serde_json::from_str(json).unwrap();
|
||||
assert_matches!(
|
||||
join_rules,
|
||||
RoomJoinRulesEventContent { join_rule: JoinRule::Restricted(_) }
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn join_rule_to_space_room_join_rule() {
|
||||
assert_eq!(SpaceRoomJoinRule::Invite, JoinRule::Invite.into());
|
||||
|
Loading…
x
Reference in New Issue
Block a user