1
0
Fork 0
mirror of https://gitlab.com/famedly/conduit.git synced 2025-08-11 17:50:59 +00:00

chore: bump ruma

This commit is contained in:
Matthias Ahouansou 2025-06-28 19:40:10 +01:00
parent 5c8b030c1e
commit 1a4a348ccf
No known key found for this signature in database
8 changed files with 164 additions and 208 deletions

24
Cargo.lock generated
View file

@ -2520,7 +2520,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma" name = "ruma"
version = "0.12.3" version = "0.12.3"
source = "git+https://github.com/ruma/ruma.git#a0e8064064dbdc6c935394c72c6f43d7bd89b92d" source = "git+https://github.com/ruma/ruma.git#e65c55fe37343e5fe3366e7bb5fc6fdca4f27655"
dependencies = [ dependencies = [
"assign", "assign",
"js_int", "js_int",
@ -2539,7 +2539,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-appservice-api" name = "ruma-appservice-api"
version = "0.12.2" version = "0.12.2"
source = "git+https://github.com/ruma/ruma.git#a0e8064064dbdc6c935394c72c6f43d7bd89b92d" source = "git+https://github.com/ruma/ruma.git#e65c55fe37343e5fe3366e7bb5fc6fdca4f27655"
dependencies = [ dependencies = [
"js_int", "js_int",
"ruma-common", "ruma-common",
@ -2551,7 +2551,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-client-api" name = "ruma-client-api"
version = "0.20.3" version = "0.20.3"
source = "git+https://github.com/ruma/ruma.git#a0e8064064dbdc6c935394c72c6f43d7bd89b92d" source = "git+https://github.com/ruma/ruma.git#e65c55fe37343e5fe3366e7bb5fc6fdca4f27655"
dependencies = [ dependencies = [
"as_variant", "as_variant",
"assign", "assign",
@ -2574,7 +2574,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-common" name = "ruma-common"
version = "0.15.2" version = "0.15.2"
source = "git+https://github.com/ruma/ruma.git#a0e8064064dbdc6c935394c72c6f43d7bd89b92d" source = "git+https://github.com/ruma/ruma.git#e65c55fe37343e5fe3366e7bb5fc6fdca4f27655"
dependencies = [ dependencies = [
"as_variant", "as_variant",
"base64 0.22.1", "base64 0.22.1",
@ -2600,12 +2600,13 @@ dependencies = [
"uuid", "uuid",
"web-time", "web-time",
"wildmatch", "wildmatch",
"zeroize",
] ]
[[package]] [[package]]
name = "ruma-events" name = "ruma-events"
version = "0.30.3" version = "0.30.3"
source = "git+https://github.com/ruma/ruma.git#a0e8064064dbdc6c935394c72c6f43d7bd89b92d" source = "git+https://github.com/ruma/ruma.git#e65c55fe37343e5fe3366e7bb5fc6fdca4f27655"
dependencies = [ dependencies = [
"as_variant", "as_variant",
"indexmap 2.9.0", "indexmap 2.9.0",
@ -2623,12 +2624,13 @@ dependencies = [
"url", "url",
"web-time", "web-time",
"wildmatch", "wildmatch",
"zeroize",
] ]
[[package]] [[package]]
name = "ruma-federation-api" name = "ruma-federation-api"
version = "0.11.1" version = "0.11.1"
source = "git+https://github.com/ruma/ruma.git#a0e8064064dbdc6c935394c72c6f43d7bd89b92d" source = "git+https://github.com/ruma/ruma.git#e65c55fe37343e5fe3366e7bb5fc6fdca4f27655"
dependencies = [ dependencies = [
"bytes", "bytes",
"headers", "headers",
@ -2650,7 +2652,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-identifiers-validation" name = "ruma-identifiers-validation"
version = "0.10.1" version = "0.10.1"
source = "git+https://github.com/ruma/ruma.git#a0e8064064dbdc6c935394c72c6f43d7bd89b92d" source = "git+https://github.com/ruma/ruma.git#e65c55fe37343e5fe3366e7bb5fc6fdca4f27655"
dependencies = [ dependencies = [
"js_int", "js_int",
"thiserror 2.0.12", "thiserror 2.0.12",
@ -2659,7 +2661,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-macros" name = "ruma-macros"
version = "0.15.1" version = "0.15.1"
source = "git+https://github.com/ruma/ruma.git#a0e8064064dbdc6c935394c72c6f43d7bd89b92d" source = "git+https://github.com/ruma/ruma.git#e65c55fe37343e5fe3366e7bb5fc6fdca4f27655"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"proc-macro-crate", "proc-macro-crate",
@ -2674,7 +2676,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-push-gateway-api" name = "ruma-push-gateway-api"
version = "0.11.0" version = "0.11.0"
source = "git+https://github.com/ruma/ruma.git#a0e8064064dbdc6c935394c72c6f43d7bd89b92d" source = "git+https://github.com/ruma/ruma.git#e65c55fe37343e5fe3366e7bb5fc6fdca4f27655"
dependencies = [ dependencies = [
"js_int", "js_int",
"ruma-common", "ruma-common",
@ -2686,7 +2688,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-signatures" name = "ruma-signatures"
version = "0.17.1" version = "0.17.1"
source = "git+https://github.com/ruma/ruma.git#a0e8064064dbdc6c935394c72c6f43d7bd89b92d" source = "git+https://github.com/ruma/ruma.git#e65c55fe37343e5fe3366e7bb5fc6fdca4f27655"
dependencies = [ dependencies = [
"base64 0.22.1", "base64 0.22.1",
"ed25519-dalek", "ed25519-dalek",
@ -2702,7 +2704,7 @@ dependencies = [
[[package]] [[package]]
name = "ruma-state-res" name = "ruma-state-res"
version = "0.13.0" version = "0.13.0"
source = "git+https://github.com/ruma/ruma.git#a0e8064064dbdc6c935394c72c6f43d7bd89b92d" source = "git+https://github.com/ruma/ruma.git#e65c55fe37343e5fe3366e7bb5fc6fdca4f27655"
dependencies = [ dependencies = [
"js_int", "js_int",
"ruma-common", "ruma-common",

View file

@ -11,7 +11,7 @@ use ruma::{
}, },
federation, federation,
}, },
directory::{Filter, PublicRoomJoinRule, PublicRoomsChunk, RoomNetwork}, directory::{Filter, PublicRoomsChunk, RoomNetwork},
events::{ events::{
room::{ room::{
avatar::RoomAvatarEventContent, avatar::RoomAvatarEventContent,
@ -19,7 +19,7 @@ use ruma::{
create::RoomCreateEventContent, create::RoomCreateEventContent,
guest_access::{GuestAccess, RoomGuestAccessEventContent}, guest_access::{GuestAccess, RoomGuestAccessEventContent},
history_visibility::{HistoryVisibility, RoomHistoryVisibilityEventContent}, history_visibility::{HistoryVisibility, RoomHistoryVisibilityEventContent},
join_rules::{JoinRule, RoomJoinRulesEventContent}, join_rules::RoomJoinRulesEventContent,
topic::RoomTopicEventContent, topic::RoomTopicEventContent,
}, },
StateEventType, StateEventType,
@ -273,18 +273,13 @@ pub(crate) async fn get_public_rooms_filtered_helper(
.room_state_get(&room_id, &StateEventType::RoomJoinRules, "")? .room_state_get(&room_id, &StateEventType::RoomJoinRules, "")?
.map(|s| { .map(|s| {
serde_json::from_str(s.content.get()) serde_json::from_str(s.content.get())
.map(|c: RoomJoinRulesEventContent| match c.join_rule { .map(|c: RoomJoinRulesEventContent| c.join_rule.kind())
JoinRule::Public => Some(PublicRoomJoinRule::Public),
JoinRule::Knock => Some(PublicRoomJoinRule::Knock),
_ => None,
})
.map_err(|e| { .map_err(|e| {
error!("Invalid room join rule event in database: {}", e); error!("Invalid room join rule event in database: {}", e);
Error::BadDatabase("Invalid room join rule event in database.") Error::BadDatabase("Invalid room join rule event in database.")
}) })
}) })
.transpose()? .transpose()?
.flatten()
.ok_or_else(|| Error::bad_database("Missing room join rule event for room."))?, .ok_or_else(|| Error::bad_database("Missing room join rule event for room."))?,
room_type: services() room_type: services()
.rooms .rooms

View file

@ -463,17 +463,15 @@ pub async fn create_room_route(
.await?; .await?;
} }
if let Some(topic) = &body.topic { if let Some(topic) = body.topic.clone() {
services() services()
.rooms .rooms
.timeline .timeline
.build_and_append_pdu( .build_and_append_pdu(
PduBuilder { PduBuilder {
event_type: TimelineEventType::RoomTopic, event_type: TimelineEventType::RoomTopic,
content: to_raw_value(&RoomTopicEventContent { content: to_raw_value(&RoomTopicEventContent::new(topic))
topic: topic.clone(), .expect("event is valid, we just created it"),
})
.expect("event is valid, we just created it"),
unsigned: None, unsigned: None,
state_key: Some("".to_owned()), state_key: Some("".to_owned()),
redacts: None, redacts: None,

View file

@ -1876,9 +1876,10 @@ impl Service {
.build_and_append_pdu( .build_and_append_pdu(
PduBuilder { PduBuilder {
event_type: TimelineEventType::RoomTopic, event_type: TimelineEventType::RoomTopic,
content: to_raw_value(&RoomTopicEventContent { content: to_raw_value(&RoomTopicEventContent::new(format!(
topic: format!("Manage {}", services().globals.server_name()), "Manage {}",
}) services().globals.server_name()
)))
.expect("event is valid, we just created it"), .expect("event is valid, we just created it"),
unsigned: None, unsigned: None,
state_key: Some("".to_owned()), state_key: Some("".to_owned()),

View file

@ -6,7 +6,8 @@ use ruma::{
room::{member::RoomMemberEventContent, redaction::RoomRedactionEventContent}, room::{member::RoomMemberEventContent, redaction::RoomRedactionEventContent},
space::child::HierarchySpaceChildEvent, space::child::HierarchySpaceChildEvent,
AnyEphemeralRoomEvent, AnyMessageLikeEvent, AnyStateEvent, AnyStrippedStateEvent, AnyEphemeralRoomEvent, AnyMessageLikeEvent, AnyStateEvent, AnyStrippedStateEvent,
AnySyncStateEvent, AnySyncTimelineEvent, AnyTimelineEvent, StateEvent, TimelineEventType, AnySyncMessageLikeEvent, AnySyncStateEvent, AnySyncTimelineEvent, AnyTimelineEvent,
StateEvent, TimelineEventType,
}, },
room_version_rules::{RedactionRules, RoomVersionRules}, room_version_rules::{RedactionRules, RoomVersionRules},
serde::Raw, serde::Raw,
@ -172,6 +173,30 @@ impl PduEvent {
serde_json::from_value(json).expect("Raw::from_value always works") serde_json::from_value(json).expect("Raw::from_value always works")
} }
#[tracing::instrument(skip(self))]
pub fn to_sync_message_like_event(&self) -> Raw<AnySyncMessageLikeEvent> {
let (redacts, content) = self.copy_redacts();
let mut json = json!({
"content": content,
"type": self.kind,
"event_id": self.event_id,
"sender": self.sender,
"origin_server_ts": self.origin_server_ts,
});
if let Some(unsigned) = &self.unsigned {
json["unsigned"] = json!(unsigned);
}
if let Some(state_key) = &self.state_key {
json["state_key"] = json!(state_key);
}
if let Some(redacts) = &redacts {
json["redacts"] = json!(redacts);
}
serde_json::from_value(json).expect("Raw::from_value always works")
}
/// This only works for events that are also AnyRoomEvents. /// This only works for events that are also AnyRoomEvents.
#[tracing::instrument(skip(self))] #[tracing::instrument(skip(self))]
pub fn to_any_event(&self) -> Raw<AnyEphemeralRoomEvent> { pub fn to_any_event(&self) -> Raw<AnyEphemeralRoomEvent> {

View file

@ -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),

View file

@ -12,14 +12,14 @@ use ruma::{
avatar::RoomAvatarEventContent, avatar::RoomAvatarEventContent,
guest_access::{GuestAccess, RoomGuestAccessEventContent}, guest_access::{GuestAccess, RoomGuestAccessEventContent},
history_visibility::{HistoryVisibility, RoomHistoryVisibilityEventContent}, history_visibility::{HistoryVisibility, RoomHistoryVisibilityEventContent},
join_rules::{AllowRule, JoinRule, RoomJoinRulesEventContent, RoomMembership}, join_rules::{AllowRule, JoinRule, RoomJoinRulesEventContent},
member::{MembershipState, RoomMemberEventContent}, member::{MembershipState, RoomMemberEventContent},
name::RoomNameEventContent, name::RoomNameEventContent,
power_levels::{RoomPowerLevels, RoomPowerLevelsEventContent}, power_levels::{RoomPowerLevels, RoomPowerLevelsEventContent},
}, },
StateEventType, StateEventType,
}, },
space::SpaceRoomJoinRule, room::{JoinRuleSummary, RoomMembership},
state_res::Event, state_res::Event,
EventId, JsOption, OwnedRoomId, OwnedServerName, OwnedUserId, RoomId, ServerName, UserId, EventId, JsOption, OwnedRoomId, OwnedServerName, OwnedUserId, RoomId, ServerName, UserId,
}; };
@ -430,7 +430,7 @@ impl Service {
pub fn get_space_room_join_rule( pub fn get_space_room_join_rule(
&self, &self,
current_room: &RoomId, current_room: &RoomId,
) -> Result<(SpaceRoomJoinRule, Vec<OwnedRoomId>), Error> { ) -> Result<(JoinRuleSummary, Vec<OwnedRoomId>), Error> {
Ok(self Ok(self
.room_state_get(current_room, &StateEventType::RoomJoinRules, "")? .room_state_get(current_room, &StateEventType::RoomJoinRules, "")?
.map(|s| { .map(|s| {
@ -447,7 +447,7 @@ impl Service {
}) })
}) })
.transpose()? .transpose()?
.unwrap_or((SpaceRoomJoinRule::Invite, vec![]))) .unwrap_or((JoinRuleSummary::Invite, vec![])))
} }
/// Returns the join rules event content of a room, if there are any and we are aware of it locally /// Returns the join rules event content of a room, if there are any and we are aware of it locally

View file

@ -68,7 +68,7 @@ impl Service {
{ {
// Thread already existed // Thread already existed
relations.count += uint!(1); relations.count += uint!(1);
relations.latest_event = pdu.to_message_like_event(); relations.latest_event = pdu.to_sync_message_like_event();
let content = serde_json::to_value(relations).expect("to_value always works"); let content = serde_json::to_value(relations).expect("to_value always works");
@ -81,7 +81,7 @@ impl Service {
} else { } else {
// New thread // New thread
let relations = BundledThread { let relations = BundledThread {
latest_event: pdu.to_message_like_event(), latest_event: pdu.to_sync_message_like_event(),
count: uint!(1), count: uint!(1),
current_user_participated: true, current_user_participated: true,
}; };