pub struct EventFactory { /* private fields */ }Implementations§
Source§impl EventFactory
impl EventFactory
pub fn new() -> Self
pub fn room(self, room_id: &RoomId) -> Self
pub fn sender(self, sender: &UserId) -> Self
Sourcepub fn event<E: EventContent>(&self, content: E) -> EventBuilder<E>
pub fn event<E: EventContent>(&self, content: E) -> EventBuilder<E>
Create an event from any event content.
Sourcepub fn text_msg(
&self,
content: impl Into<String>,
) -> EventBuilder<RoomMessageEventContent>
pub fn text_msg( &self, content: impl Into<String>, ) -> EventBuilder<RoomMessageEventContent>
Create a new plain text m.room.message.
Sourcepub fn emote(
&self,
content: impl Into<String>,
) -> EventBuilder<RoomMessageEventContent>
pub fn emote( &self, content: impl Into<String>, ) -> EventBuilder<RoomMessageEventContent>
Create a new plain emote m.room.message.
Sourcepub fn member(&self, member: &UserId) -> EventBuilder<RoomMemberEventContent>
pub fn member(&self, member: &UserId) -> EventBuilder<RoomMemberEventContent>
Create a new m.room.member event for the given member.
The given member will be used as the sender as well as the state_key
of the m.room.member event, unless the sender was already using
EventFactory::sender(), in that case only the state key will be
set to the given member.
The membership field of the content is set to
MembershipState::Join.
use matrix_sdk_test::event_factory::EventFactory;
use ruma::{
events::{
room::member::{MembershipState, RoomMemberEventContent},
SyncStateEvent,
},
room_id,
serde::Raw,
user_id,
};
let factory = EventFactory::new().room(room_id!("!test:localhost"));
let event: Raw<SyncStateEvent<RoomMemberEventContent>> = factory
.member(user_id!("@alice:localhost"))
.display_name("Alice")
.into_raw();Sourcepub fn room_tombstone(
&self,
body: impl Into<String>,
replacement: &RoomId,
) -> EventBuilder<RoomTombstoneEventContent>
pub fn room_tombstone( &self, body: impl Into<String>, replacement: &RoomId, ) -> EventBuilder<RoomTombstoneEventContent>
Create a tombstone state event for the room.
Sourcepub fn room_topic(
&self,
topic: impl Into<String>,
) -> EventBuilder<RoomTopicEventContent>
pub fn room_topic( &self, topic: impl Into<String>, ) -> EventBuilder<RoomTopicEventContent>
Create a state event for the topic.
Sourcepub fn room_name(
&self,
name: impl Into<String>,
) -> EventBuilder<RoomNameEventContent>
pub fn room_name( &self, name: impl Into<String>, ) -> EventBuilder<RoomNameEventContent>
Create a state event for the room name.
Sourcepub fn room_avatar(&self) -> EventBuilder<RoomAvatarEventContent>
pub fn room_avatar(&self) -> EventBuilder<RoomAvatarEventContent>
Create an empty state event for the room avatar.
Sourcepub fn member_hints(
&self,
service_members: BTreeSet<OwnedUserId>,
) -> EventBuilder<MemberHintsEventContent>
pub fn member_hints( &self, service_members: BTreeSet<OwnedUserId>, ) -> EventBuilder<MemberHintsEventContent>
Create a new m.member_hints event with the given service members.
use std::collections::BTreeSet;
use matrix_sdk_test::event_factory::EventFactory;
use ruma::{
events::{member_hints::MemberHintsEventContent, SyncStateEvent},
owned_user_id, room_id,
serde::Raw,
user_id,
};
let factory = EventFactory::new().room(room_id!("!test:localhost"));
let event: Raw<SyncStateEvent<MemberHintsEventContent>> = factory
.member_hints(BTreeSet::from([owned_user_id!("@alice:localhost")]))
.sender(user_id!("@alice:localhost"))
.into_raw();Sourcepub fn text_html(
&self,
plain: impl Into<String>,
html: impl Into<String>,
) -> EventBuilder<RoomMessageEventContent>
pub fn text_html( &self, plain: impl Into<String>, html: impl Into<String>, ) -> EventBuilder<RoomMessageEventContent>
Create a new plain/html m.room.message.
Sourcepub fn notice(
&self,
content: impl Into<String>,
) -> EventBuilder<RoomMessageEventContent>
pub fn notice( &self, content: impl Into<String>, ) -> EventBuilder<RoomMessageEventContent>
Create a new plain notice m.room.message.
Sourcepub fn reaction(
&self,
event_id: &EventId,
annotation: impl Into<String>,
) -> EventBuilder<ReactionEventContent>
pub fn reaction( &self, event_id: &EventId, annotation: impl Into<String>, ) -> EventBuilder<ReactionEventContent>
Add a reaction to an event.
Sourcepub fn redaction(
&self,
event_id: &EventId,
) -> EventBuilder<RoomRedactionEventContent>
pub fn redaction( &self, event_id: &EventId, ) -> EventBuilder<RoomRedactionEventContent>
Create a live redaction for the given event id.
Note: this is not a redacted event, but a redaction event, that will cause another event to be redacted.
Sourcepub fn redacted<T: RedactedMessageLikeEventContent>(
&self,
redacter: &UserId,
content: T,
) -> EventBuilder<T>
pub fn redacted<T: RedactedMessageLikeEventContent>( &self, redacter: &UserId, content: T, ) -> EventBuilder<T>
Create a redacted event, with extra information in the unsigned section about the redaction itself.
Sourcepub fn redacted_state<T: RedactedStateEventContent>(
&self,
redacter: &UserId,
state_key: impl Into<String>,
content: T,
) -> EventBuilder<T>
pub fn redacted_state<T: RedactedStateEventContent>( &self, redacter: &UserId, state_key: impl Into<String>, content: T, ) -> EventBuilder<T>
Create a redacted state event, with extra information in the unsigned section about the redaction itself.
Sourcepub fn poll_start(
&self,
content: impl Into<String>,
poll_question: impl Into<String>,
answers: Vec<impl Into<String>>,
) -> EventBuilder<UnstablePollStartEventContent>
pub fn poll_start( &self, content: impl Into<String>, poll_question: impl Into<String>, answers: Vec<impl Into<String>>, ) -> EventBuilder<UnstablePollStartEventContent>
Create a poll start event given a text, the question and the possible answers.
Sourcepub fn poll_edit(
&self,
edited_event_id: &EventId,
poll_question: impl Into<String>,
answers: Vec<impl Into<String>>,
) -> EventBuilder<ReplacementUnstablePollStartEventContent>
pub fn poll_edit( &self, edited_event_id: &EventId, poll_question: impl Into<String>, answers: Vec<impl Into<String>>, ) -> EventBuilder<ReplacementUnstablePollStartEventContent>
Create a poll edit event given the new question and possible answers.
Sourcepub fn poll_response(
&self,
answers: Vec<impl Into<String>>,
poll_start_id: &EventId,
) -> EventBuilder<UnstablePollResponseEventContent>
pub fn poll_response( &self, answers: Vec<impl Into<String>>, poll_start_id: &EventId, ) -> EventBuilder<UnstablePollResponseEventContent>
Create a poll response with the given answer id and the associated poll start event id.
Sourcepub fn poll_end(
&self,
content: impl Into<String>,
poll_start_id: &EventId,
) -> EventBuilder<UnstablePollEndEventContent>
pub fn poll_end( &self, content: impl Into<String>, poll_start_id: &EventId, ) -> EventBuilder<UnstablePollEndEventContent>
Create a poll response with the given text and the associated poll start event id.
Sourcepub fn image(
&self,
filename: String,
url: OwnedMxcUri,
) -> EventBuilder<RoomMessageEventContent>
pub fn image( &self, filename: String, url: OwnedMxcUri, ) -> EventBuilder<RoomMessageEventContent>
Creates a plain (unencrypted) image event content referencing the given MXC ID.
Sourcepub fn typing(&self, user_ids: Vec<&UserId>) -> EventBuilder<TypingEventContent>
pub fn typing(&self, user_ids: Vec<&UserId>) -> EventBuilder<TypingEventContent>
Create a typing notification event.
Sourcepub fn read_receipts(&self) -> ReadReceiptBuilder<'_>
pub fn read_receipts(&self) -> ReadReceiptBuilder<'_>
Create a read receipt event.
Sourcepub fn set_next_ts(&self, value: u64)
pub fn set_next_ts(&self, value: u64)
Set the next server timestamp.
Timestamps will continue to increase by 1 (millisecond) from that value.