|
|
|
@ -8,24 +8,22 @@ use lru_cache::LruCache; |
|
|
|
use ruma::{ |
|
|
|
use ruma::{ |
|
|
|
api::{ |
|
|
|
api::{ |
|
|
|
client::{self, error::ErrorKind, space::SpaceHierarchyRoomsChunk}, |
|
|
|
client::{self, error::ErrorKind, space::SpaceHierarchyRoomsChunk}, |
|
|
|
federation::{ |
|
|
|
federation::{self, space::SpaceHierarchyParentSummary}, |
|
|
|
self, |
|
|
|
|
|
|
|
space::{SpaceHierarchyChildSummary, SpaceHierarchyParentSummary}, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
events::{ |
|
|
|
events::{ |
|
|
|
room::{ |
|
|
|
room::{ |
|
|
|
avatar::RoomAvatarEventContent, |
|
|
|
avatar::RoomAvatarEventContent, |
|
|
|
canonical_alias::RoomCanonicalAliasEventContent, |
|
|
|
canonical_alias::RoomCanonicalAliasEventContent, |
|
|
|
create::RoomCreateEventContent, |
|
|
|
create::RoomCreateEventContent, |
|
|
|
|
|
|
|
encryption::RoomEncryptionEventContent, |
|
|
|
join_rules::{JoinRule, RoomJoinRulesEventContent}, |
|
|
|
join_rules::{JoinRule, RoomJoinRulesEventContent}, |
|
|
|
topic::RoomTopicEventContent, |
|
|
|
topic::RoomTopicEventContent, |
|
|
|
}, |
|
|
|
}, |
|
|
|
space::child::{HierarchySpaceChildEvent, SpaceChildEventContent}, |
|
|
|
space::child::{HierarchySpaceChildEvent, SpaceChildEventContent}, |
|
|
|
StateEventType, |
|
|
|
StateEventType, |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
room::{JoinRuleSummary, RestrictedSummary, RoomSummary}, |
|
|
|
serde::Raw, |
|
|
|
serde::Raw, |
|
|
|
space::SpaceRoomJoinRule, |
|
|
|
|
|
|
|
OwnedRoomId, OwnedServerName, RoomId, ServerName, UInt, UserId, |
|
|
|
OwnedRoomId, OwnedServerName, RoomId, ServerName, UInt, UserId, |
|
|
|
}; |
|
|
|
}; |
|
|
|
use tokio::sync::Mutex; |
|
|
|
use tokio::sync::Mutex; |
|
|
|
@ -130,31 +128,13 @@ pub struct Service { |
|
|
|
impl From<CachedSpaceHierarchySummary> for SpaceHierarchyRoomsChunk { |
|
|
|
impl From<CachedSpaceHierarchySummary> for SpaceHierarchyRoomsChunk { |
|
|
|
fn from(value: CachedSpaceHierarchySummary) -> Self { |
|
|
|
fn from(value: CachedSpaceHierarchySummary) -> Self { |
|
|
|
let SpaceHierarchyParentSummary { |
|
|
|
let SpaceHierarchyParentSummary { |
|
|
|
canonical_alias, |
|
|
|
summary, |
|
|
|
name, |
|
|
|
|
|
|
|
num_joined_members, |
|
|
|
|
|
|
|
room_id, |
|
|
|
|
|
|
|
topic, |
|
|
|
|
|
|
|
world_readable, |
|
|
|
|
|
|
|
guest_can_join, |
|
|
|
|
|
|
|
avatar_url, |
|
|
|
|
|
|
|
join_rule, |
|
|
|
|
|
|
|
room_type, |
|
|
|
|
|
|
|
children_state, |
|
|
|
children_state, |
|
|
|
.. |
|
|
|
.. |
|
|
|
} = value.summary; |
|
|
|
} = value.summary; |
|
|
|
|
|
|
|
|
|
|
|
SpaceHierarchyRoomsChunk { |
|
|
|
SpaceHierarchyRoomsChunk { |
|
|
|
canonical_alias, |
|
|
|
summary, |
|
|
|
name, |
|
|
|
|
|
|
|
num_joined_members, |
|
|
|
|
|
|
|
room_id, |
|
|
|
|
|
|
|
topic, |
|
|
|
|
|
|
|
world_readable, |
|
|
|
|
|
|
|
guest_can_join, |
|
|
|
|
|
|
|
avatar_url, |
|
|
|
|
|
|
|
join_rule, |
|
|
|
|
|
|
|
room_type, |
|
|
|
|
|
|
|
children_state, |
|
|
|
children_state, |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -187,7 +167,7 @@ impl Service { |
|
|
|
.await? |
|
|
|
.await? |
|
|
|
{ |
|
|
|
{ |
|
|
|
Some(SummaryAccessibility::Accessible(summary)) => { |
|
|
|
Some(SummaryAccessibility::Accessible(summary)) => { |
|
|
|
children.push((*summary).into()); |
|
|
|
children.push(summary.summary); |
|
|
|
} |
|
|
|
} |
|
|
|
Some(SummaryAccessibility::Inaccessible) => { |
|
|
|
Some(SummaryAccessibility::Inaccessible) => { |
|
|
|
inaccessible_children.push(child); |
|
|
|
inaccessible_children.push(child); |
|
|
|
@ -227,12 +207,8 @@ impl Service { |
|
|
|
.as_ref() |
|
|
|
.as_ref() |
|
|
|
{ |
|
|
|
{ |
|
|
|
return Ok(if let Some(cached) = cached { |
|
|
|
return Ok(if let Some(cached) = cached { |
|
|
|
if is_accessible_child( |
|
|
|
if is_accessible_child(current_room, &cached.summary.summary.join_rule, &identifier) |
|
|
|
current_room, |
|
|
|
{ |
|
|
|
&cached.summary.join_rule, |
|
|
|
|
|
|
|
&identifier, |
|
|
|
|
|
|
|
&cached.summary.allowed_room_ids, |
|
|
|
|
|
|
|
) { |
|
|
|
|
|
|
|
Some(SummaryAccessibility::Accessible(Box::new( |
|
|
|
Some(SummaryAccessibility::Accessible(Box::new( |
|
|
|
cached.summary.clone(), |
|
|
|
cached.summary.clone(), |
|
|
|
))) |
|
|
|
))) |
|
|
|
@ -303,35 +279,14 @@ impl Service { |
|
|
|
current_room.clone(), |
|
|
|
current_room.clone(), |
|
|
|
Some(CachedSpaceHierarchySummary { |
|
|
|
Some(CachedSpaceHierarchySummary { |
|
|
|
summary: { |
|
|
|
summary: { |
|
|
|
let SpaceHierarchyChildSummary { |
|
|
|
|
|
|
|
canonical_alias, |
|
|
|
|
|
|
|
name, |
|
|
|
|
|
|
|
num_joined_members, |
|
|
|
|
|
|
|
room_id, |
|
|
|
|
|
|
|
topic, |
|
|
|
|
|
|
|
world_readable, |
|
|
|
|
|
|
|
guest_can_join, |
|
|
|
|
|
|
|
avatar_url, |
|
|
|
|
|
|
|
join_rule, |
|
|
|
|
|
|
|
room_type, |
|
|
|
|
|
|
|
allowed_room_ids, |
|
|
|
|
|
|
|
} = child; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SpaceHierarchyParentSummary { |
|
|
|
SpaceHierarchyParentSummary { |
|
|
|
canonical_alias, |
|
|
|
children_state: get_stripped_space_child_events( |
|
|
|
name, |
|
|
|
&child.room_id, |
|
|
|
num_joined_members, |
|
|
|
) |
|
|
|
room_id: room_id.clone(), |
|
|
|
.await? |
|
|
|
topic, |
|
|
|
.unwrap(), |
|
|
|
world_readable, |
|
|
|
|
|
|
|
guest_can_join, |
|
|
|
summary: child, |
|
|
|
avatar_url, |
|
|
|
|
|
|
|
join_rule, |
|
|
|
|
|
|
|
room_type, |
|
|
|
|
|
|
|
children_state: get_stripped_space_child_events(&room_id) |
|
|
|
|
|
|
|
.await? |
|
|
|
|
|
|
|
.unwrap(), |
|
|
|
|
|
|
|
allowed_room_ids, |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
}), |
|
|
|
}), |
|
|
|
@ -340,9 +295,8 @@ impl Service { |
|
|
|
} |
|
|
|
} |
|
|
|
if is_accessible_child( |
|
|
|
if is_accessible_child( |
|
|
|
current_room, |
|
|
|
current_room, |
|
|
|
&response.room.join_rule, |
|
|
|
&response.room.summary.join_rule, |
|
|
|
&Identifier::UserId(user_id), |
|
|
|
&Identifier::UserId(user_id), |
|
|
|
&response.room.allowed_room_ids, |
|
|
|
|
|
|
|
) { |
|
|
|
) { |
|
|
|
return Ok(Some(SummaryAccessibility::Accessible(Box::new( |
|
|
|
return Ok(Some(SummaryAccessibility::Accessible(Box::new( |
|
|
|
summary.clone(), |
|
|
|
summary.clone(), |
|
|
|
@ -403,17 +357,7 @@ impl Service { |
|
|
|
.transpose()? |
|
|
|
.transpose()? |
|
|
|
.unwrap_or(JoinRule::Invite); |
|
|
|
.unwrap_or(JoinRule::Invite); |
|
|
|
|
|
|
|
|
|
|
|
let allowed_room_ids = services() |
|
|
|
if !is_accessible_child(current_room, &join_rule.clone().into(), &identifier) { |
|
|
|
.rooms |
|
|
|
|
|
|
|
.state_accessor |
|
|
|
|
|
|
|
.allowed_room_ids(join_rule.clone()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if !is_accessible_child( |
|
|
|
|
|
|
|
current_room, |
|
|
|
|
|
|
|
&join_rule.clone().into(), |
|
|
|
|
|
|
|
&identifier, |
|
|
|
|
|
|
|
&allowed_room_ids, |
|
|
|
|
|
|
|
) { |
|
|
|
|
|
|
|
debug!("User is not allowed to see room {room_id}"); |
|
|
|
debug!("User is not allowed to see room {room_id}"); |
|
|
|
// This error will be caught later
|
|
|
|
// This error will be caught later
|
|
|
|
return Err(Error::BadRequest( |
|
|
|
return Err(Error::BadRequest( |
|
|
|
@ -425,70 +369,82 @@ impl Service { |
|
|
|
let join_rule = join_rule.into(); |
|
|
|
let join_rule = join_rule.into(); |
|
|
|
|
|
|
|
|
|
|
|
Ok(SpaceHierarchyParentSummary { |
|
|
|
Ok(SpaceHierarchyParentSummary { |
|
|
|
canonical_alias: services() |
|
|
|
summary: RoomSummary { |
|
|
|
.rooms |
|
|
|
canonical_alias: services() |
|
|
|
.state_accessor |
|
|
|
.rooms |
|
|
|
.room_state_get(room_id, &StateEventType::RoomCanonicalAlias, "")? |
|
|
|
.state_accessor |
|
|
|
.map_or(Ok(None), |s| { |
|
|
|
.room_state_get(room_id, &StateEventType::RoomCanonicalAlias, "")? |
|
|
|
serde_json::from_str(s.content.get()) |
|
|
|
.map_or(Ok(None), |s| { |
|
|
|
.map(|c: RoomCanonicalAliasEventContent| c.alias) |
|
|
|
serde_json::from_str(s.content.get()) |
|
|
|
.map_err(|_| { |
|
|
|
.map(|c: RoomCanonicalAliasEventContent| c.alias) |
|
|
|
Error::bad_database("Invalid canonical alias event in database.") |
|
|
|
.map_err(|_| { |
|
|
|
}) |
|
|
|
Error::bad_database("Invalid canonical alias event in database.") |
|
|
|
})?, |
|
|
|
}) |
|
|
|
name: services().rooms.state_accessor.get_name(room_id)?, |
|
|
|
})?, |
|
|
|
num_joined_members: services() |
|
|
|
name: services().rooms.state_accessor.get_name(room_id)?, |
|
|
|
.rooms |
|
|
|
num_joined_members: services() |
|
|
|
.state_cache |
|
|
|
.rooms |
|
|
|
.room_joined_count(room_id)? |
|
|
|
.state_cache |
|
|
|
.unwrap_or_else(|| { |
|
|
|
.room_joined_count(room_id)? |
|
|
|
warn!("Room {} has no member count", room_id); |
|
|
|
.unwrap_or_else(|| { |
|
|
|
0 |
|
|
|
warn!("Room {} has no member count", room_id); |
|
|
|
}) |
|
|
|
0 |
|
|
|
.try_into() |
|
|
|
|
|
|
|
.expect("user count should not be that big"), |
|
|
|
|
|
|
|
room_id: room_id.to_owned(), |
|
|
|
|
|
|
|
topic: services() |
|
|
|
|
|
|
|
.rooms |
|
|
|
|
|
|
|
.state_accessor |
|
|
|
|
|
|
|
.room_state_get(room_id, &StateEventType::RoomTopic, "")? |
|
|
|
|
|
|
|
.map_or(Ok(None), |s| { |
|
|
|
|
|
|
|
serde_json::from_str(s.content.get()) |
|
|
|
|
|
|
|
.map(|c: RoomTopicEventContent| Some(c.topic)) |
|
|
|
|
|
|
|
.map_err(|_| { |
|
|
|
|
|
|
|
error!("Invalid room topic event in database for room {}", room_id); |
|
|
|
|
|
|
|
Error::bad_database("Invalid room topic event in database.") |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
})?, |
|
|
|
|
|
|
|
world_readable: services().rooms.state_accessor.world_readable(room_id)?, |
|
|
|
|
|
|
|
guest_can_join: services().rooms.state_accessor.guest_can_join(room_id)?, |
|
|
|
|
|
|
|
avatar_url: services() |
|
|
|
|
|
|
|
.rooms |
|
|
|
|
|
|
|
.state_accessor |
|
|
|
|
|
|
|
.room_state_get(room_id, &StateEventType::RoomAvatar, "")? |
|
|
|
|
|
|
|
.map(|s| { |
|
|
|
|
|
|
|
serde_json::from_str(s.content.get()) |
|
|
|
|
|
|
|
.map(|c: RoomAvatarEventContent| c.url) |
|
|
|
|
|
|
|
.map_err(|_| Error::bad_database("Invalid room avatar event in database.")) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
.transpose()? |
|
|
|
|
|
|
|
// url is now an Option<String> so we must flatten
|
|
|
|
|
|
|
|
.flatten(), |
|
|
|
|
|
|
|
join_rule, |
|
|
|
|
|
|
|
room_type: services() |
|
|
|
|
|
|
|
.rooms |
|
|
|
|
|
|
|
.state_accessor |
|
|
|
|
|
|
|
.room_state_get(room_id, &StateEventType::RoomCreate, "")? |
|
|
|
|
|
|
|
.map(|s| { |
|
|
|
|
|
|
|
serde_json::from_str::<RoomCreateEventContent>(s.content.get()).map_err(|e| { |
|
|
|
|
|
|
|
error!("Invalid room create event in database: {}", e); |
|
|
|
|
|
|
|
Error::BadDatabase("Invalid room create event in database.") |
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
.try_into() |
|
|
|
.transpose()? |
|
|
|
.expect("user count should not be that big"), |
|
|
|
.and_then(|e| e.room_type), |
|
|
|
room_id: room_id.to_owned(), |
|
|
|
|
|
|
|
topic: services() |
|
|
|
|
|
|
|
.rooms |
|
|
|
|
|
|
|
.state_accessor |
|
|
|
|
|
|
|
.room_state_get(room_id, &StateEventType::RoomTopic, "")? |
|
|
|
|
|
|
|
.map_or(Ok(None), |s| { |
|
|
|
|
|
|
|
serde_json::from_str(s.content.get()) |
|
|
|
|
|
|
|
.map(|c: RoomTopicEventContent| Some(c.topic)) |
|
|
|
|
|
|
|
.map_err(|_| { |
|
|
|
|
|
|
|
error!("Invalid room topic event in database for room {}", room_id); |
|
|
|
|
|
|
|
Error::bad_database("Invalid room topic event in database.") |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
})?, |
|
|
|
|
|
|
|
world_readable: services().rooms.state_accessor.world_readable(room_id)?, |
|
|
|
|
|
|
|
guest_can_join: services().rooms.state_accessor.guest_can_join(room_id)?, |
|
|
|
|
|
|
|
avatar_url: services() |
|
|
|
|
|
|
|
.rooms |
|
|
|
|
|
|
|
.state_accessor |
|
|
|
|
|
|
|
.room_state_get(room_id, &StateEventType::RoomAvatar, "")? |
|
|
|
|
|
|
|
.map(|s| { |
|
|
|
|
|
|
|
serde_json::from_str(s.content.get()) |
|
|
|
|
|
|
|
.map(|c: RoomAvatarEventContent| c.url) |
|
|
|
|
|
|
|
.map_err(|_| { |
|
|
|
|
|
|
|
Error::bad_database("Invalid room avatar event in database.") |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
.transpose()? |
|
|
|
|
|
|
|
// url is now an Option<String> so we must flatten
|
|
|
|
|
|
|
|
.flatten(), |
|
|
|
|
|
|
|
join_rule, |
|
|
|
|
|
|
|
room_type: services() |
|
|
|
|
|
|
|
.rooms |
|
|
|
|
|
|
|
.state_accessor |
|
|
|
|
|
|
|
.room_state_get(room_id, &StateEventType::RoomCreate, "")? |
|
|
|
|
|
|
|
.map(|s| { |
|
|
|
|
|
|
|
serde_json::from_str::<RoomCreateEventContent>(s.content.get()).map_err( |
|
|
|
|
|
|
|
|e| { |
|
|
|
|
|
|
|
error!("Invalid room create event in database: {}", e); |
|
|
|
|
|
|
|
Error::BadDatabase("Invalid room create event in database.") |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
.transpose()? |
|
|
|
|
|
|
|
.and_then(|e| e.room_type), |
|
|
|
|
|
|
|
encryption: services() |
|
|
|
|
|
|
|
.rooms |
|
|
|
|
|
|
|
.state_accessor |
|
|
|
|
|
|
|
.room_state_get(room_id, &StateEventType::RoomEncryption, "")? |
|
|
|
|
|
|
|
.and_then(|pdu| serde_json::from_str(pdu.content.get()).ok()) |
|
|
|
|
|
|
|
.map(|content: RoomEncryptionEventContent| content.algorithm), |
|
|
|
|
|
|
|
room_version: services().rooms.state.get_room_version(room_id).ok(), |
|
|
|
|
|
|
|
}, |
|
|
|
children_state, |
|
|
|
children_state, |
|
|
|
allowed_room_ids, |
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -681,9 +637,8 @@ async fn get_stripped_space_child_events( |
|
|
|
/// With the given identifier, checks if a room is accessible
|
|
|
|
/// With the given identifier, checks if a room is accessible
|
|
|
|
fn is_accessible_child( |
|
|
|
fn is_accessible_child( |
|
|
|
current_room: &OwnedRoomId, |
|
|
|
current_room: &OwnedRoomId, |
|
|
|
join_rule: &SpaceRoomJoinRule, |
|
|
|
join_rule: &JoinRuleSummary, |
|
|
|
identifier: &Identifier<'_>, |
|
|
|
identifier: &Identifier<'_>, |
|
|
|
allowed_room_ids: &Vec<OwnedRoomId>, |
|
|
|
|
|
|
|
) -> bool { |
|
|
|
) -> bool { |
|
|
|
// Note: unwrap_or_default for bool means false
|
|
|
|
// Note: unwrap_or_default for bool means false
|
|
|
|
match identifier { |
|
|
|
match identifier { |
|
|
|
@ -717,7 +672,7 @@ fn is_accessible_child( |
|
|
|
} |
|
|
|
} |
|
|
|
} // Takes care of joinrules
|
|
|
|
} // Takes care of joinrules
|
|
|
|
match join_rule { |
|
|
|
match join_rule { |
|
|
|
SpaceRoomJoinRule::Restricted => { |
|
|
|
JoinRuleSummary::Restricted(RestrictedSummary { allowed_room_ids }) => { |
|
|
|
for room in allowed_room_ids { |
|
|
|
for room in allowed_room_ids { |
|
|
|
match identifier { |
|
|
|
match identifier { |
|
|
|
Identifier::UserId(user) => { |
|
|
|
Identifier::UserId(user) => { |
|
|
|
@ -744,10 +699,10 @@ fn is_accessible_child( |
|
|
|
} |
|
|
|
} |
|
|
|
false |
|
|
|
false |
|
|
|
} |
|
|
|
} |
|
|
|
SpaceRoomJoinRule::Public |
|
|
|
JoinRuleSummary::Public | JoinRuleSummary::Knock | JoinRuleSummary::KnockRestricted(_) => { |
|
|
|
| SpaceRoomJoinRule::Knock |
|
|
|
true |
|
|
|
| SpaceRoomJoinRule::KnockRestricted => true, |
|
|
|
} |
|
|
|
SpaceRoomJoinRule::Invite | SpaceRoomJoinRule::Private => false, |
|
|
|
JoinRuleSummary::Invite | JoinRuleSummary::Private => false, |
|
|
|
// Custom join rule
|
|
|
|
// Custom join rule
|
|
|
|
_ => false, |
|
|
|
_ => false, |
|
|
|
} |
|
|
|
} |
|
|
|
@ -756,31 +711,13 @@ fn is_accessible_child( |
|
|
|
// Here because cannot implement `From` across ruma-federation-api and ruma-client-api types
|
|
|
|
// Here because cannot implement `From` across ruma-federation-api and ruma-client-api types
|
|
|
|
fn summary_to_chunk(summary: SpaceHierarchyParentSummary) -> SpaceHierarchyRoomsChunk { |
|
|
|
fn summary_to_chunk(summary: SpaceHierarchyParentSummary) -> SpaceHierarchyRoomsChunk { |
|
|
|
let SpaceHierarchyParentSummary { |
|
|
|
let SpaceHierarchyParentSummary { |
|
|
|
canonical_alias, |
|
|
|
summary, |
|
|
|
name, |
|
|
|
|
|
|
|
num_joined_members, |
|
|
|
|
|
|
|
room_id, |
|
|
|
|
|
|
|
topic, |
|
|
|
|
|
|
|
world_readable, |
|
|
|
|
|
|
|
guest_can_join, |
|
|
|
|
|
|
|
avatar_url, |
|
|
|
|
|
|
|
join_rule, |
|
|
|
|
|
|
|
room_type, |
|
|
|
|
|
|
|
children_state, |
|
|
|
children_state, |
|
|
|
.. |
|
|
|
.. |
|
|
|
} = summary; |
|
|
|
} = summary; |
|
|
|
|
|
|
|
|
|
|
|
SpaceHierarchyRoomsChunk { |
|
|
|
SpaceHierarchyRoomsChunk { |
|
|
|
canonical_alias, |
|
|
|
summary, |
|
|
|
name, |
|
|
|
|
|
|
|
num_joined_members, |
|
|
|
|
|
|
|
room_id, |
|
|
|
|
|
|
|
topic, |
|
|
|
|
|
|
|
world_readable, |
|
|
|
|
|
|
|
guest_can_join, |
|
|
|
|
|
|
|
avatar_url, |
|
|
|
|
|
|
|
join_rule, |
|
|
|
|
|
|
|
room_type, |
|
|
|
|
|
|
|
children_state, |
|
|
|
children_state, |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -807,20 +744,20 @@ fn get_parent_children_via( |
|
|
|
|
|
|
|
|
|
|
|
#[cfg(test)] |
|
|
|
#[cfg(test)] |
|
|
|
mod tests { |
|
|
|
mod tests { |
|
|
|
use ruma::{ |
|
|
|
use ruma::{owned_room_id, owned_server_name}; |
|
|
|
api::federation::space::SpaceHierarchyParentSummaryInit, owned_room_id, owned_server_name, |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
use super::*; |
|
|
|
use super::*; |
|
|
|
|
|
|
|
|
|
|
|
#[test] |
|
|
|
#[test] |
|
|
|
fn get_summary_children() { |
|
|
|
fn get_summary_children() { |
|
|
|
let summary: SpaceHierarchyParentSummary = SpaceHierarchyParentSummaryInit { |
|
|
|
let summary: SpaceHierarchyParentSummary = SpaceHierarchyParentSummary { |
|
|
|
num_joined_members: UInt::from(1_u32), |
|
|
|
summary: RoomSummary::new( |
|
|
|
room_id: owned_room_id!("!root:example.org"), |
|
|
|
owned_room_id!("!root:example.org"), |
|
|
|
world_readable: true, |
|
|
|
JoinRuleSummary::Public, |
|
|
|
guest_can_join: true, |
|
|
|
true, |
|
|
|
join_rule: SpaceRoomJoinRule::Public, |
|
|
|
UInt::from(1_u32), |
|
|
|
|
|
|
|
true, |
|
|
|
|
|
|
|
), |
|
|
|
children_state: vec![ |
|
|
|
children_state: vec![ |
|
|
|
serde_json::from_str( |
|
|
|
serde_json::from_str( |
|
|
|
r#"{ |
|
|
|
r#"{ |
|
|
|
@ -867,9 +804,7 @@ mod tests { |
|
|
|
) |
|
|
|
) |
|
|
|
.unwrap(), |
|
|
|
.unwrap(), |
|
|
|
], |
|
|
|
], |
|
|
|
allowed_room_ids: vec![], |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
.into(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assert_eq!( |
|
|
|
assert_eq!( |
|
|
|
get_parent_children_via(summary.clone(), false), |
|
|
|
get_parent_children_via(summary.clone(), false), |
|
|
|
|