events: Implement From<JoinRule> for SpaceRoomJoinRule
This commit is contained in:
parent
76c58b143a
commit
c00085b520
@ -20,6 +20,7 @@ Improvements:
|
|||||||
the target user's power level.
|
the target user's power level.
|
||||||
- Add unstable support for manually marking rooms as unread through [MSC2867](https://github.com/matrix-org/matrix-spec-proposals/pull/2867)
|
- Add unstable support for manually marking rooms as unread through [MSC2867](https://github.com/matrix-org/matrix-spec-proposals/pull/2867)
|
||||||
and the room account data `m.marked_unread` event (unstable type `com.famedly.marked_unread`)
|
and the room account data `m.marked_unread` event (unstable type `com.famedly.marked_unread`)
|
||||||
|
- Implement `From<JoinRule>` for `SpaceRoomJoinRule`
|
||||||
|
|
||||||
# 0.27.11
|
# 0.27.11
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
use std::{borrow::Cow, collections::BTreeMap};
|
use std::{borrow::Cow, collections::BTreeMap};
|
||||||
|
|
||||||
use ruma_common::{serde::from_raw_json_value, OwnedRoomId};
|
use ruma_common::{serde::from_raw_json_value, space::SpaceRoomJoinRule, OwnedRoomId};
|
||||||
use ruma_macros::EventContent;
|
use ruma_macros::EventContent;
|
||||||
use serde::{
|
use serde::{
|
||||||
de::{Deserializer, Error},
|
de::{Deserializer, Error},
|
||||||
@ -157,6 +157,12 @@ impl<'de> Deserialize<'de> for JoinRule {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<JoinRule> for SpaceRoomJoinRule {
|
||||||
|
fn from(value: JoinRule) -> Self {
|
||||||
|
value.as_str().into()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Configuration of the `Restricted` join rule.
|
/// Configuration of the `Restricted` join rule.
|
||||||
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
|
||||||
@ -249,7 +255,10 @@ mod tests {
|
|||||||
use assert_matches2::assert_matches;
|
use assert_matches2::assert_matches;
|
||||||
use ruma_common::owned_room_id;
|
use ruma_common::owned_room_id;
|
||||||
|
|
||||||
use super::{AllowRule, JoinRule, OriginalSyncRoomJoinRulesEvent, RoomJoinRulesEventContent};
|
use super::{
|
||||||
|
AllowRule, JoinRule, OriginalSyncRoomJoinRulesEvent, Restricted, RoomJoinRulesEventContent,
|
||||||
|
SpaceRoomJoinRule,
|
||||||
|
};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn deserialize() {
|
fn deserialize() {
|
||||||
@ -315,4 +324,20 @@ mod tests {
|
|||||||
assert_matches!(&allow_rule, AllowRule::_Custom(_));
|
assert_matches!(&allow_rule, AllowRule::_Custom(_));
|
||||||
assert_eq!(serde_json::to_string(&allow_rule).unwrap(), json);
|
assert_eq!(serde_json::to_string(&allow_rule).unwrap(), json);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn join_rule_to_space_room_join_rule() {
|
||||||
|
assert_eq!(SpaceRoomJoinRule::Invite, JoinRule::Invite.into());
|
||||||
|
assert_eq!(SpaceRoomJoinRule::Knock, JoinRule::Knock.into());
|
||||||
|
assert_eq!(
|
||||||
|
SpaceRoomJoinRule::KnockRestricted,
|
||||||
|
JoinRule::KnockRestricted(Restricted::default()).into()
|
||||||
|
);
|
||||||
|
assert_eq!(SpaceRoomJoinRule::Public, JoinRule::Public.into());
|
||||||
|
assert_eq!(SpaceRoomJoinRule::Private, JoinRule::Private.into());
|
||||||
|
assert_eq!(
|
||||||
|
SpaceRoomJoinRule::Restricted,
|
||||||
|
JoinRule::Restricted(Restricted::default()).into()
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user