events: Add {RoomJoinRulesEvent, SyncJoinRulesEvent}::join_rule

This commit is contained in:
Jonas Platte 2022-04-13 15:31:40 +02:00
parent 548232ef5a
commit 16f2021c59
No known key found for this signature in database
GPG Key ID: BBA95679259D342F

View File

@ -49,6 +49,26 @@ impl<'de> Deserialize<'de> for RoomJoinRulesEventContent {
} }
} }
impl RoomJoinRulesEvent {
/// Obtain the join rule, regardless of whether this event is redacted.
pub fn join_rule(&self) -> &JoinRule {
match self {
Self::Original(ev) => &ev.content.join_rule,
Self::Redacted(ev) => &ev.content.join_rule,
}
}
}
impl SyncRoomJoinRulesEvent {
/// Obtain the join rule, regardless of whether this event is redacted.
pub fn join_rule(&self) -> &JoinRule {
match self {
Self::Original(ev) => &ev.content.join_rule,
Self::Redacted(ev) => &ev.content.join_rule,
}
}
}
/// The rule used for users wishing to join this room. /// The rule used for users wishing to join this room.
/// ///
/// This type can hold an arbitrary string. To check for formats that are not available as a /// This type can hold an arbitrary string. To check for formats that are not available as a