feat(test): add event factory methods for creating space rooms and populating parent-children relationships.
This commit is contained in:
committed by
Stefan Ceriu
parent
97d6f57aee
commit
759eeeb27f
@@ -72,10 +72,12 @@ use ruma::{
|
||||
tombstone::RoomTombstoneEventContent,
|
||||
topic::RoomTopicEventContent,
|
||||
},
|
||||
space::{child::SpaceChildEventContent, parent::SpaceParentEventContent},
|
||||
sticker::StickerEventContent,
|
||||
typing::TypingEventContent,
|
||||
},
|
||||
push::Ruleset,
|
||||
room::RoomType,
|
||||
room_version_rules::AuthorizationRules,
|
||||
serde::Raw,
|
||||
server_name,
|
||||
@@ -462,6 +464,12 @@ impl EventBuilder<RoomCreateEventContent> {
|
||||
self.content.predecessor = None;
|
||||
self
|
||||
}
|
||||
|
||||
/// Sets the `m.room.create` `type` field to `m.space`.
|
||||
pub fn with_space_type(mut self) -> Self {
|
||||
self.content.room_type = Some(RoomType::Space);
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl EventBuilder<StickerEventContent> {
|
||||
@@ -1024,6 +1032,30 @@ impl EventFactory {
|
||||
builder
|
||||
}
|
||||
|
||||
/// Create a new `m.space.child` state event.
|
||||
pub fn space_child(
|
||||
&self,
|
||||
parent: OwnedRoomId,
|
||||
child: OwnedRoomId,
|
||||
) -> EventBuilder<SpaceChildEventContent> {
|
||||
let mut event = self.event(SpaceChildEventContent::new(vec![]));
|
||||
event.room = Some(parent);
|
||||
event.state_key = Some(child.to_string());
|
||||
event
|
||||
}
|
||||
|
||||
/// Create a new `m.space.parent` state event.
|
||||
pub fn space_parent(
|
||||
&self,
|
||||
parent: OwnedRoomId,
|
||||
child: OwnedRoomId,
|
||||
) -> EventBuilder<SpaceParentEventContent> {
|
||||
let mut event = self.event(SpaceParentEventContent::new(vec![]));
|
||||
event.state_key = Some(parent.to_string());
|
||||
event.room = Some(child);
|
||||
event
|
||||
}
|
||||
|
||||
/// Set the next server timestamp.
|
||||
///
|
||||
/// Timestamps will continue to increase by 1 (millisecond) from that value.
|
||||
|
||||
Reference in New Issue
Block a user