Struct matrix_sdk::room::Joined
source · [−]pub struct Joined { /* private fields */ }Expand description
A room in the joined state.
The JoinedRoom contains all methods specific to a Room with type
RoomType::Joined. Operations may fail once the underlying Room changes
RoomType.
Implementations
sourceimpl Joined
impl Joined
sourcepub async fn ban_user(&self, user_id: &UserId, reason: Option<&str>) -> Result<()>
pub async fn ban_user(&self, user_id: &UserId, reason: Option<&str>) -> Result<()>
Ban the user with UserId from this room.
Arguments
-
user_id- The user to ban withUserId. -
reason- The reason for banning this user.
sourcepub async fn kick_user(
&self,
user_id: &UserId,
reason: Option<&str>
) -> Result<()>
pub async fn kick_user(
&self,
user_id: &UserId,
reason: Option<&str>
) -> Result<()>
Kick a user out of this room.
Arguments
-
user_id- TheUserIdof the user that should be kicked out of the room. -
reason- Optional reason why the room member is being kicked out.
sourcepub async fn invite_user_by_id(&self, user_id: &UserId) -> Result<()>
pub async fn invite_user_by_id(&self, user_id: &UserId) -> Result<()>
Invite the specified user by UserId to this room.
Arguments
user_id- TheUserIdof the user to invite to the room.
sourcepub async fn invite_user_by_3pid(&self, invite_id: Invite3pid<'_>) -> Result<()>
pub async fn invite_user_by_3pid(&self, invite_id: Invite3pid<'_>) -> Result<()>
Invite the specified user by third party id to this room.
Arguments
invite_id- A third party id of a user to invite to the room.
sourcepub async fn typing_notice(&self, typing: bool) -> Result<()>
pub async fn typing_notice(&self, typing: bool) -> Result<()>
Activate typing notice for this room.
The typing notice remains active for 4s. It can be deactivate at any
point by setting typing to false. If this method is called while
the typing notice is active nothing will happen. This method can be
called on every key stroke, since it will do nothing while typing is
active.
Arguments
typing- Whether the user is typing or has stopped typing.
Examples
use std::time::Duration;
use matrix_sdk::ruma::api::client::typing::create_typing_event::v3::Typing;
let room_id = room_id!("!SVkFJHzfwvuaIEawgC:localhost");
if let Some(room) = client.get_joined_room(&room_id) {
room.typing_notice(true).await?
}sourcepub async fn read_receipt(&self, event_id: &EventId) -> Result<()>
pub async fn read_receipt(&self, event_id: &EventId) -> Result<()>
Send a request to notify this room that the user has read specific event.
Arguments
event_id- TheEventIdspecifies the event to set the read receipt on.
sourcepub async fn read_marker(
&self,
fully_read: &EventId,
read_receipt: Option<&EventId>
) -> Result<()>
pub async fn read_marker(
&self,
fully_read: &EventId,
read_receipt: Option<&EventId>
) -> Result<()>
Send a request to notify this room that the user has read up to specific event.
Arguments
-
fully_read - The
EventIdof the event the user has read to. -
read_receipt - An
EventIdto specify the event to set the read receipt on.
sourcepub async fn enable_encryption(&self) -> Result<()>
pub async fn enable_encryption(&self) -> Result<()>
Enable End-to-end encryption in this room.
This method will be a noop if encryption is already enabled, otherwise
sends a m.room.encryption state event to the room. This might fail if
you don’t have the appropriate power level to enable end-to-end
encryption.
A sync needs to be received to update the local room state. This method will wait for a sync to be received, this might time out if no sync loop is running or if the server is slow.
Examples
let room_id = room_id!("!SVkFJHzfwvuaIEawgC:localhost");
if let Some(room) = client.get_joined_room(&room_id) {
room.enable_encryption().await?
}sourcepub async fn send(
&self,
content: impl MessageLikeEventContent,
txn_id: Option<&TransactionId>
) -> Result<Response>
pub async fn send(
&self,
content: impl MessageLikeEventContent,
txn_id: Option<&TransactionId>
) -> Result<Response>
Send a room message to this room.
Returns the parsed response from the server.
If the encryption feature is enabled this method will transparently encrypt the room message if this room is encrypted.
Note: If you just want to send a custom JSON payload to a room, you
can use the Joined::send_raw() method for that.
Arguments
-
content- The content of the message event. -
txn_id- A locally-unique ID describing a message transaction with the homeserver. Unless you’re doing something special, you can pass inNonewhich will create a suitable one for you automatically.- On the sending side, this field is used for re-trying earlier failed transactions. Subsequent messages must never re-use an earlier transaction ID.
- On the receiving side, the field is used for recognizing our own
messages when they arrive down the sync: the server includes the
ID in the
MessageLikeUnsignedfieldtransaction_idof the correspondingSyncMessageLikeEvent, but only for the sending device. Other devices will not see it. This is then used to ignore events sent by our own device and/or to implement local echo.
Example
use matrix_sdk::ruma::{
events::{
macros::EventContent,
room::message::{RoomMessageEventContent, TextMessageEventContent},
},
uint, MilliSecondsSinceUnixEpoch, TransactionId,
};
let content = RoomMessageEventContent::text_plain("Hello world");
let txn_id = TransactionId::new();
if let Some(room) = client.get_joined_room(&room_id) {
room.send(content, Some(&txn_id)).await?;
}
// Custom events work too:
#[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
#[ruma_event(type = "org.shiny_new_2fa.token", kind = MessageLike)]
struct TokenEventContent {
token: String,
#[serde(rename = "exp")]
expires_at: MilliSecondsSinceUnixEpoch,
}
let content = TokenEventContent {
token: generate_token(),
expires_at: {
let now = MilliSecondsSinceUnixEpoch::now();
MilliSecondsSinceUnixEpoch(now.0 + uint!(30_000))
},
};
let txn_id = TransactionId::new();
if let Some(room) = client.get_joined_room(&room_id) {
room.send(content, Some(&txn_id)).await?;
}sourcepub async fn send_raw(
&self,
content: Value,
event_type: &str,
txn_id: Option<&TransactionId>
) -> Result<Response>
pub async fn send_raw(
&self,
content: Value,
event_type: &str,
txn_id: Option<&TransactionId>
) -> Result<Response>
Send a room message to this room from a json Value.
Returns the parsed response from the server.
If the encryption feature is enabled this method will transparently encrypt the room message if this room is encrypted.
This method is equivalent to the Joined::send() method but allows
sending custom JSON payloads, e.g. constructed using the
serde_json::json!() macro.
Arguments
-
content- The content of the event as a jsonValue. -
event_type- The type of the event. -
txn_id- A locally-unique ID describing a message transaction with the homeserver. Unless you’re doing something special, you can pass inNonewhich will create a suitable one for you automatically.- On the sending side, this field is used for re-trying earlier failed transactions. Subsequent messages must never re-use an earlier transaction ID.
- On the receiving side, the field is used for recognizing our own
messages when they arrive down the sync: the server includes the
ID in the
StateUnsignedfieldtransaction_idof the correspondingSyncMessageLikeEvent, but only for the sending device. Other devices will not see it. This is then used to ignore events sent by our own device and/or to implement local echo.
Example
use serde_json::json;
let content = json!({
"body": "Hello world",
});
if let Some(room) = client.get_joined_room(&room_id) {
room.send_raw(content, "m.room.message", None).await?;
}sourcepub async fn send_attachment(
&self,
body: &str,
content_type: &Mime,
data: &[u8],
config: AttachmentConfig<'_>
) -> Result<Response>
pub async fn send_attachment(
&self,
body: &str,
content_type: &Mime,
data: &[u8],
config: AttachmentConfig<'_>
) -> Result<Response>
Send an attachment to this room.
This will upload the given data that the reader produces using the
upload() method and post an event to the given room.
If the room is encrypted and the encryption feature is enabled the
upload will be encrypted.
This is a convenience method that calls the
Client::upload() and afterwards the
send().
Arguments
-
body- A textual representation of the media that is going to be uploaded. Usually the file name. -
content_type- The type of the media, this will be used as the content-type header. -
reader- AReaderthat will be used to fetch the raw bytes of the media. -
config- Metadata and configuration for the attachment.
Examples
let mut image = fs::read("/home/example/my-cat.jpg")?;
if let Some(room) = client.get_joined_room(&room_id) {
room.send_attachment(
"My favorite cat",
&mime::IMAGE_JPEG,
&image,
AttachmentConfig::new(),
).await?;
}sourcepub async fn send_state_event(
&self,
content: impl StateEventContent<StateKey = EmptyStateKey>
) -> Result<Response>
pub async fn send_state_event(
&self,
content: impl StateEventContent<StateKey = EmptyStateKey>
) -> Result<Response>
Send a state event with an empty state key to the homeserver.
For state events with a non-empty state key, see
send_state_event_for_key.
Returns the parsed response from the server.
Arguments
content- The content of the state event.
Example
use matrix_sdk::ruma::{
events::{
macros::EventContent, room::encryption::RoomEncryptionEventContent,
EmptyStateKey,
},
EventEncryptionAlgorithm,
};
let encryption_event_content = RoomEncryptionEventContent::new(
EventEncryptionAlgorithm::MegolmV1AesSha2,
);
joined_room.send_state_event(encryption_event_content).await?;
// Custom event:
#[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
#[ruma_event(
type = "org.matrix.msc_9000.xxx",
kind = State,
state_key_type = EmptyStateKey,
)]
struct XxxStateEventContent {/* fields... */}
let content: XxxStateEventContent = todo!();
joined_room.send_state_event(content).await?;sourcepub async fn send_state_event_for_key<C, K>(
&self,
state_key: &K,
content: C
) -> Result<Response>where
C: StateEventContent,
C::StateKey: Borrow<K>,
K: AsRef<str> + ?Sized,
pub async fn send_state_event_for_key<C, K>(
&self,
state_key: &K,
content: C
) -> Result<Response>where
C: StateEventContent,
C::StateKey: Borrow<K>,
K: AsRef<str> + ?Sized,
Send a state event to the homeserver.
Returns the parsed response from the server.
Arguments
-
content- The content of the state event. -
state_key- A unique key which defines the overwriting semantics for this piece of room state.
Example
use matrix_sdk::ruma::{
events::{
macros::EventContent,
room::member::{RoomMemberEventContent, MembershipState},
},
mxc_uri,
};
let avatar_url = mxc_uri!("mxc://example.org/avatar").to_owned();
let mut content = RoomMemberEventContent::new(MembershipState::Join);
content.avatar_url = Some(avatar_url);
joined_room.send_state_event_for_key(ruma::user_id!("@foo:bar.com"), content).await?;
// Custom event:
#[derive(Clone, Debug, Deserialize, Serialize, EventContent)]
#[ruma_event(type = "org.matrix.msc_9000.xxx", kind = State, state_key_type = String)]
struct XxxStateEventContent { /* fields... */ }
let content: XxxStateEventContent = todo!();
joined_room.send_state_event_for_key("foo", content).await?;sourcepub async fn send_state_event_raw(
&self,
content: Value,
event_type: &str,
state_key: &str
) -> Result<Response>
pub async fn send_state_event_raw(
&self,
content: Value,
event_type: &str,
state_key: &str
) -> Result<Response>
Send a raw room state event to the homeserver.
Returns the parsed response from the server.
Arguments
-
content- The raw content of the state event. -
event_type- The type of the event that we’re sending out. -
state_key- A unique key which defines the overwriting semantics for this piece of room state. This value is often a zero-length string.
Example
use serde_json::json;
let content = json!({
"avatar_url": "mxc://example.org/SEsfnsuifSDFSSEF",
"displayname": "Alice Margatroid",
"membership": "join"
});
if let Some(room) = client.get_joined_room(&room_id) {
room.send_state_event_raw(content, "m.room.member", "").await?;
}sourcepub async fn redact(
&self,
event_id: &EventId,
reason: Option<&str>,
txn_id: Option<OwnedTransactionId>
) -> HttpResult<Response>
pub async fn redact(
&self,
event_id: &EventId,
reason: Option<&str>,
txn_id: Option<OwnedTransactionId>
) -> HttpResult<Response>
Strips all information out of an event of the room.
Returns the [redact_event::v3::Response] from the server.
This cannot be undone. Users may redact their own events, and any user with a power level greater than or equal to the redact power level of the room may redact events there.
Arguments
-
event_id- The ID of the event to redact -
reason- The reason for the event being redacted. -
txn_id- A unique ID that can be attached to this event as its transaction ID. If not given one is created for the message.
Example
use matrix_sdk::ruma::event_id;
if let Some(room) = client.get_joined_room(&room_id) {
let event_id = event_id!("$xxxxxx:example.org");
let reason = Some("Indecent material");
room.redact(&event_id, reason, None).await?;
}Methods from Deref<Target = Common>
sourcepub fn client(&self) -> Client
pub fn client(&self) -> Client
Get the inner client saved in this room instance.
Returns the client this room is part of.
sourcepub async fn avatar(&self, format: MediaFormat) -> Result<Option<Vec<u8>>>
pub async fn avatar(&self, format: MediaFormat) -> Result<Option<Vec<u8>>>
Gets the avatar of this room, if set.
Returns the avatar. If a thumbnail is requested no guarantee on the size of the image is given.
Arguments
format- The desired format of the avatar.
Example
let client = Client::new(homeserver).await.unwrap();
client.login(user, "password", None, None).await.unwrap();
let room_id = room_id!("!roomid:example.com");
let room = client.get_joined_room(&room_id).unwrap();
if let Some(avatar) = room.avatar(MediaFormat::File).await.unwrap() {
std::fs::write("avatar.png", avatar);
}sourcepub async fn messages(&self, options: MessagesOptions<'_>) -> Result<Messages>
pub async fn messages(&self, options: MessagesOptions<'_>) -> Result<Messages>
Sends a request to /_matrix/client/r0/rooms/{room_id}/messages and
returns a Messages struct that contains a chunk of room and state
events (RoomEvent and AnyStateEvent).
With the encryption feature, messages are decrypted if possible. If decryption fails for an individual message, that message is returned undecrypted.
Examples
use matrix_sdk::{room::MessagesOptions, Client};
let options =
MessagesOptions::backward().from("t47429-4392820_219380_26003_2265");
let mut client = Client::new(homeserver).await.unwrap();
let room = client.get_joined_room(room_id!("!roomid:example.com")).unwrap();
assert!(room.messages(options).await.is_ok());sourcepub fn add_event_handler<Ev, Ctx, H>(&self, handler: H) -> EventHandlerHandlewhere
Ev: SyncEvent + DeserializeOwned + Send + 'static,
H: EventHandler<Ev, Ctx>,
<H::Future as Future>::Output: EventHandlerResult,
pub fn add_event_handler<Ev, Ctx, H>(&self, handler: H) -> EventHandlerHandlewhere
Ev: SyncEvent + DeserializeOwned + Send + 'static,
H: EventHandler<Ev, Ctx>,
<H::Future as Future>::Output: EventHandlerResult,
Register a handler for events of a specific type, within this room.
This method works the same way as Client::add_event_handler, except
that the handler will only be called for events within this room. See
that method for more details on event handler functions.
room.add_event_handler(hdl) is equivalent to
client.add_room_event_handler(room_id, hdl). Use whichever one is more
convenient in your use case.
sourcepub async fn event(&self, event_id: &EventId) -> Result<TimelineEvent>
pub async fn event(&self, event_id: &EventId) -> Result<TimelineEvent>
Fetch the event with the given EventId in this room.
sourcepub async fn sync_members(&self) -> Result<Option<MembersResponse>>
pub async fn sync_members(&self) -> Result<Option<MembersResponse>>
Sync the member list with the server.
This method will de-duplicate requests if it is called multiple times in
quick succession, in that case the return value will be None.
sourcepub async fn active_members(&self) -> Result<Vec<RoomMember>>
pub async fn active_members(&self) -> Result<Vec<RoomMember>>
Get active members for this room, includes invited, joined members.
Note: This method will fetch the members from the homeserver if the member list isn’t synchronized due to member lazy loading. Because of that, it might panic if it isn’t run on a tokio thread.
Use active_members_no_sync() if you want a method that doesn’t do any requests.
sourcepub async fn active_members_no_sync(&self) -> Result<Vec<RoomMember>>
pub async fn active_members_no_sync(&self) -> Result<Vec<RoomMember>>
Get active members for this room, includes invited, joined members.
Note: This method will not fetch the members from the homeserver if the member list isn’t synchronized due to member lazy loading. Thus, members could be missing from the list.
Use active_members() if you want to ensure to always get the full member list.
sourcepub async fn joined_members(&self) -> Result<Vec<RoomMember>>
pub async fn joined_members(&self) -> Result<Vec<RoomMember>>
Get all the joined members of this room.
Note: This method will fetch the members from the homeserver if the member list isn’t synchronized due to member lazy loading. Because of that it might panic if it isn’t run on a tokio thread.
Use joined_members_no_sync() if you want a method that doesn’t do any requests.
sourcepub async fn joined_members_no_sync(&self) -> Result<Vec<RoomMember>>
pub async fn joined_members_no_sync(&self) -> Result<Vec<RoomMember>>
Get all the joined members of this room.
Note: This method will not fetch the members from the homeserver if the member list isn’t synchronized due to member lazy loading. Thus, members could be missing from the list.
Use joined_members() if you want to ensure to always get the full member list.
sourcepub async fn get_member(&self, user_id: &UserId) -> Result<Option<RoomMember>>
pub async fn get_member(&self, user_id: &UserId) -> Result<Option<RoomMember>>
Get a specific member of this room.
Note: This method will fetch the members from the homeserver if the member list isn’t synchronized due to member lazy loading. Because of that it might panic if it isn’t run on a tokio thread.
Use get_member_no_sync() if you want a method that doesn’t do any requests.
Arguments
user_id- The ID of the user that should be fetched out of the store.
sourcepub async fn get_member_no_sync(
&self,
user_id: &UserId
) -> Result<Option<RoomMember>>
pub async fn get_member_no_sync(
&self,
user_id: &UserId
) -> Result<Option<RoomMember>>
Get a specific member of this room.
Note: This method will not fetch the members from the homeserver if the member list isn’t synchronized due to member lazy loading. Thus, members could be missing.
Use get_member() if you want to ensure to always have the full member list to chose from.
Arguments
user_id- The ID of the user that should be fetched out of the store.
sourcepub async fn members(&self) -> Result<Vec<RoomMember>>
pub async fn members(&self) -> Result<Vec<RoomMember>>
Get all members for this room, includes invited, joined and left members.
Note: This method will fetch the members from the homeserver if the member list isn’t synchronized due to member lazy loading. Because of that it might panic if it isn’t run on a tokio thread.
Use members_no_sync() if you want a method that doesn’t do any requests.
sourcepub async fn members_no_sync(&self) -> Result<Vec<RoomMember>>
pub async fn members_no_sync(&self) -> Result<Vec<RoomMember>>
Get all members for this room, includes invited, joined and left members.
Note: This method will not fetch the members from the homeserver if the member list isn’t synchronized due to member lazy loading. Thus, members could be missing.
Use members() if you want to ensure to always get the full member list.
sourcepub async fn get_state_events(
&self,
event_type: StateEventType
) -> Result<Vec<Raw<AnySyncStateEvent>>>
pub async fn get_state_events(
&self,
event_type: StateEventType
) -> Result<Vec<Raw<AnySyncStateEvent>>>
Get all state events of a given type in this room.
sourcepub async fn get_state_events_static<C>(
&self
) -> Result<Vec<Raw<SyncStateEvent<C>>>>where
C: StaticEventContent + StateEventContent + RedactContent,
C::Redacted: RedactedStateEventContent,
pub async fn get_state_events_static<C>(
&self
) -> Result<Vec<Raw<SyncStateEvent<C>>>>where
C: StaticEventContent + StateEventContent + RedactContent,
C::Redacted: RedactedStateEventContent,
Get all state events of a given statically-known type in this room.
Example
use matrix_sdk::ruma::{
events::room::member::SyncRoomMemberEvent, serde::Raw,
};
let room_members: Vec<Raw<SyncRoomMemberEvent>> =
room.get_state_events_static().await?;sourcepub async fn get_state_event(
&self,
event_type: StateEventType,
state_key: &str
) -> Result<Option<Raw<AnySyncStateEvent>>>
pub async fn get_state_event(
&self,
event_type: StateEventType,
state_key: &str
) -> Result<Option<Raw<AnySyncStateEvent>>>
Get a specific state event in this room.
sourcepub async fn get_state_event_static<C>(
&self
) -> Result<Option<Raw<SyncStateEvent<C>>>>where
C: StaticEventContent + StateEventContent<StateKey = EmptyStateKey> + RedactContent,
C::Redacted: RedactedStateEventContent,
pub async fn get_state_event_static<C>(
&self
) -> Result<Option<Raw<SyncStateEvent<C>>>>where
C: StaticEventContent + StateEventContent<StateKey = EmptyStateKey> + RedactContent,
C::Redacted: RedactedStateEventContent,
Get a specific state event of statically-known type with an empty state key in this room.
Example
use matrix_sdk::ruma::events::room::power_levels::SyncRoomPowerLevelsEvent;
let power_levels: SyncRoomPowerLevelsEvent = room
.get_state_event_static()
.await?
.expect("every room has a power_levels event")
.deserialize()?;sourcepub async fn get_state_event_static_for_key<C, K>(
&self,
state_key: &K
) -> Result<Option<Raw<SyncStateEvent<C>>>>where
C: StaticEventContent + StateEventContent + RedactContent,
C::StateKey: Borrow<K>,
C::Redacted: RedactedStateEventContent,
K: AsRef<str> + ?Sized + Sync,
pub async fn get_state_event_static_for_key<C, K>(
&self,
state_key: &K
) -> Result<Option<Raw<SyncStateEvent<C>>>>where
C: StaticEventContent + StateEventContent + RedactContent,
C::StateKey: Borrow<K>,
C::Redacted: RedactedStateEventContent,
K: AsRef<str> + ?Sized + Sync,
Get a specific state event of statically-known type in this room.
Example
use matrix_sdk::ruma::{
events::room::member::SyncRoomMemberEvent, serde::Raw, user_id,
};
let member_event: Option<Raw<SyncRoomMemberEvent>> = room
.get_state_event_static_for_key(user_id!("@alice:example.org"))
.await?;sourcepub async fn account_data(
&self,
data_type: RoomAccountDataEventType
) -> Result<Option<Raw<AnyRoomAccountDataEvent>>>
pub async fn account_data(
&self,
data_type: RoomAccountDataEventType
) -> Result<Option<Raw<AnyRoomAccountDataEvent>>>
Get account data in this room.
sourcepub async fn account_data_static<C>(
&self
) -> Result<Option<Raw<RoomAccountDataEvent<C>>>>where
C: StaticEventContent + RoomAccountDataEventContent,
pub async fn account_data_static<C>(
&self
) -> Result<Option<Raw<RoomAccountDataEvent<C>>>>where
C: StaticEventContent + RoomAccountDataEventContent,
Get account data of statically-known type in this room.
Example
use matrix_sdk::ruma::events::fully_read::FullyReadEventContent;
match room.account_data_static::<FullyReadEventContent>().await? {
Some(fully_read) => {
println!("Found read marker: {:?}", fully_read.deserialize()?)
}
None => println!("No read marker for this room"),
}sourcepub async fn contains_only_verified_devices(&self) -> Result<bool>
Available on crate feature e2e-encryption only.
pub async fn contains_only_verified_devices(&self) -> Result<bool>
e2e-encryption only.Check if all members of this room are verified and all their devices are verified.
Returns true if all devices in the room are verified, otherwise false.
sourcepub async fn set_tag(
&self,
tag: TagName,
tag_info: TagInfo
) -> HttpResult<Response>
pub async fn set_tag(
&self,
tag: TagName,
tag_info: TagInfo
) -> HttpResult<Response>
Adds a tag to the room, or updates it if it already exists.
Returns the [create_tag::v3::Response] from the server.
Arguments
-
tag- The tag to add or update. -
tag_info- Information about the tag, generally containing theorderparameter.
Example
use matrix_sdk::ruma::events::tag::TagInfo;
if let Some(room) = client.get_joined_room(&room_id) {
let mut tag_info = TagInfo::new();
tag_info.order = Some(0.9);
let user_tag = UserTagName::from_str("u.work")?;
room.set_tag(TagName::User(user_tag), tag_info).await?;
}sourcepub async fn remove_tag(&self, tag: TagName) -> HttpResult<Response>
pub async fn remove_tag(&self, tag: TagName) -> HttpResult<Response>
Removes a tag from the room.
Returns the [delete_tag::v3::Response] from the server.
Arguments
tag- The tag to remove.
sourcepub async fn set_is_direct(&self, is_direct: bool) -> Result<()>
pub async fn set_is_direct(&self, is_direct: bool) -> Result<()>
Sets whether this room is a DM.
When setting this room as DM, it will be marked as DM for all active members of the room. When unsetting this room as DM, it will be unmarked as DM for all users, not just the members.
Arguments
is_direct- Whether to mark this room as direct.
sourcepub async fn decrypt_event(
&self,
event: &Raw<OriginalSyncRoomEncryptedEvent>
) -> Result<TimelineEvent>
Available on crate feature e2e-encryption only.
pub async fn decrypt_event(
&self,
event: &Raw<OriginalSyncRoomEncryptedEvent>
) -> Result<TimelineEvent>
e2e-encryption only.Tries to decrypt a room event.
Arguments
event- The room event to be decrypted.
Returns the decrypted event.
sourcepub async fn route(&self) -> Result<Vec<OwnedServerName>>
pub async fn route(&self) -> Result<Vec<OwnedServerName>>
Get a list of servers that should know this room.
Uses the synced members of the room and the suggested routing algorithm from the Matrix spec.
Returns at most three servers.
sourcepub async fn matrix_to_permalink(&self) -> Result<MatrixToUri>
pub async fn matrix_to_permalink(&self) -> Result<MatrixToUri>
Get a matrix.to permalink to this room.
If this room has an alias, we use it. Otherwise, we try to use the synced members in the room for routing the room ID.
sourcepub async fn matrix_permalink(&self, join: bool) -> Result<MatrixUri>
pub async fn matrix_permalink(&self, join: bool) -> Result<MatrixUri>
sourcepub async fn matrix_to_event_permalink(
&self,
event_id: impl Into<OwnedEventId>
) -> Result<MatrixToUri>
pub async fn matrix_to_event_permalink(
&self,
event_id: impl Into<OwnedEventId>
) -> Result<MatrixToUri>
Get a matrix.to permalink to an event in this room.
We try to use the synced members in the room for routing the room ID.
Note: This method does not check if the given event ID is actually part of this room. It needs to be checked before calling this method otherwise the permalink won’t work.
Arguments
event_id- The ID of the event.
sourcepub async fn matrix_event_permalink(
&self,
event_id: impl Into<OwnedEventId>
) -> Result<MatrixUri>
pub async fn matrix_event_permalink(
&self,
event_id: impl Into<OwnedEventId>
) -> Result<MatrixUri>
Get a matrix: permalink to an event in this room.
We try to use the synced members in the room for routing the room ID.
Note: This method does not check if the given event ID is actually part of this room. It needs to be checked before calling this method otherwise the permalink won’t work.
Arguments
event_id- The ID of the event.
Methods from Deref<Target = BaseRoom>
sourcepub fn own_user_id(&self) -> &UserId
pub fn own_user_id(&self) -> &UserId
Get our own user id.
sourcepub fn unread_notification_counts(&self) -> UnreadNotificationsCount
pub fn unread_notification_counts(&self) -> UnreadNotificationsCount
Get the unread notification counts.
sourcepub fn are_members_synced(&self) -> bool
pub fn are_members_synced(&self) -> bool
Check if the room has it’s members fully synced.
Members might be missing if lazy member loading was enabled for the sync.
Returns true if no members are missing, false otherwise.
sourcepub fn last_prev_batch(&self) -> Option<String>
pub fn last_prev_batch(&self) -> Option<String>
Get the prev_batch token that was received from the last sync. May be
None if the last sync contained the full room history.
sourcepub fn avatar_url(&self) -> Option<OwnedMxcUri>
pub fn avatar_url(&self) -> Option<OwnedMxcUri>
Get the avatar url of this room.
sourcepub fn canonical_alias(&self) -> Option<OwnedRoomAliasId>
pub fn canonical_alias(&self) -> Option<OwnedRoomAliasId>
Get the canonical alias of this room.
sourcepub fn alt_aliases(&self) -> Vec<OwnedRoomAliasId, Global>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A>where
A: Allocator,
pub fn alt_aliases(&self) -> Vec<OwnedRoomAliasId, Global>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A>where
A: Allocator,
A: Allocator,
Get the canonical alias of this room.
sourcepub fn create_content(&self) -> Option<RoomCreateEventContent>
pub fn create_content(&self) -> Option<RoomCreateEventContent>
Get the m.room.create content of this room.
This usually isn’t optional but some servers might not send an
m.room.create event as the first event for a given room, thus this can
be optional.
It can also be redacted in current room versions, leaving only the
creator field.
sourcepub fn direct_targets(&self) -> HashSet<OwnedUserId, RandomState>
pub fn direct_targets(&self) -> HashSet<OwnedUserId, RandomState>
If this room is a direct message, get the members that we’re sharing the room with.
Note: The member list might have been modified in the meantime and the targets might not even be in the room anymore. This setting should only be considered as guidance.
sourcepub fn is_encrypted(&self) -> bool
pub fn is_encrypted(&self) -> bool
Is the room encrypted.
sourcepub fn encryption_settings(&self) -> Option<RoomEncryptionEventContent>
pub fn encryption_settings(&self) -> Option<RoomEncryptionEventContent>
Get the m.room.encryption content that enabled end to end encryption
in the room.
sourcepub fn guest_access(&self) -> GuestAccess
pub fn guest_access(&self) -> GuestAccess
Get the guest access policy of this room.
sourcepub fn history_visibility(&self) -> HistoryVisibility
pub fn history_visibility(&self) -> HistoryVisibility
Get the history visibility policy of this room.
sourcepub fn max_power_level(&self) -> i64
pub fn max_power_level(&self) -> i64
Get the maximum power level that this room contains.
This is useful if one wishes to normalize the power levels, e.g. from 0-100 where 100 would be the max power level.
sourcepub fn is_tombstoned(&self) -> bool
pub fn is_tombstoned(&self) -> bool
Has the room been tombstoned.
sourcepub fn tombstone(&self) -> Option<RoomTombstoneEventContent>
pub fn tombstone(&self) -> Option<RoomTombstoneEventContent>
Get the m.room.tombstone content of this room if there is one.
sourcepub async fn display_name(
&self
) -> impl Future<Output = Result<DisplayName, StoreError>>
pub async fn display_name(
&self
) -> impl Future<Output = Result<DisplayName, StoreError>>
Calculate the canonical display name of the room, taking into account its name, aliases and members.
The display name is calculated according to this algorithm.
sourcepub async fn joined_user_ids(
&self
) -> impl Future<Output = Result<Vec<OwnedUserId, Global>, StoreError>>
pub async fn joined_user_ids(
&self
) -> impl Future<Output = Result<Vec<OwnedUserId, Global>, StoreError>>
Get the list of users ids that are considered to be joined members of this room.
sourcepub async fn members(
&self
) -> impl Future<Output = Result<Vec<RoomMember, Global>, StoreError>>
pub async fn members(
&self
) -> impl Future<Output = Result<Vec<RoomMember, Global>, StoreError>>
Get the all RoomMembers of this room that are known to the store.
sourcepub async fn joined_members(
&self
) -> impl Future<Output = Result<Vec<RoomMember, Global>, StoreError>>
pub async fn joined_members(
&self
) -> impl Future<Output = Result<Vec<RoomMember, Global>, StoreError>>
Get the list of RoomMembers that are considered to be joined members
of this room.
sourcepub async fn active_members(
&self
) -> impl Future<Output = Result<Vec<RoomMember, Global>, StoreError>>
pub async fn active_members(
&self
) -> impl Future<Output = Result<Vec<RoomMember, Global>, StoreError>>
Get the list of RoomMembers that are considered to be joined or
invited members of this room.
sourcepub fn clone_info(&self) -> RoomInfo
pub fn clone_info(&self) -> RoomInfo
Clone the inner RoomInfo
sourcepub fn update_summary(&self, summary: RoomInfo)
pub fn update_summary(&self, summary: RoomInfo)
Update the summary with given RoomInfo
sourcepub async fn get_member(
&self,
user_id: &UserId
) -> impl Future<Output = Result<Option<RoomMember>, StoreError>>
pub async fn get_member(
&self,
user_id: &UserId
) -> impl Future<Output = Result<Option<RoomMember>, StoreError>>
Get the RoomMember with the given user_id.
Returns None if the member was never part of this room, otherwise
return a RoomMember that can be in a joined, invited, left, banned
state.
Get the Tags for this room.
sourcepub async fn user_read_receipt(
&self,
user_id: &UserId
) -> impl Future<Output = Result<Option<(OwnedEventId, Receipt)>, StoreError>>
pub async fn user_read_receipt(
&self,
user_id: &UserId
) -> impl Future<Output = Result<Option<(OwnedEventId, Receipt)>, StoreError>>
Get the read receipt as a EventId and Receipt tuple for the given
user_id in this room.
sourcepub async fn event_read_receipts(
&self,
event_id: &EventId
) -> impl Future<Output = Result<Vec<(OwnedUserId, Receipt), Global>, StoreError>>
pub async fn event_read_receipts(
&self,
event_id: &EventId
) -> impl Future<Output = Result<Vec<(OwnedUserId, Receipt), Global>, StoreError>>
Get the read receipts as a list of UserId and Receipt tuples for the
given event_id in this room.