mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-05-07 07:27:45 -04:00
ffi: Add binding for get_dm_room
This commit is contained in:
@@ -3,6 +3,7 @@ use std::sync::{Arc, RwLock};
|
||||
use anyhow::{anyhow, Context};
|
||||
use matrix_sdk::{
|
||||
media::{MediaFileHandle as SdkMediaFileHandle, MediaFormat, MediaRequest, MediaThumbnailSize},
|
||||
room::Room as SdkRoom,
|
||||
ruma::{
|
||||
api::client::{
|
||||
account::whoami,
|
||||
@@ -497,6 +498,13 @@ impl Client {
|
||||
pub fn rooms(&self) -> Vec<Arc<Room>> {
|
||||
self.client.rooms().into_iter().map(|room| Arc::new(Room::new(room))).collect()
|
||||
}
|
||||
|
||||
pub fn get_dm_room(&self, user_id: String) -> Result<Option<Arc<Room>>, ClientError> {
|
||||
let user_id = UserId::parse(user_id)?;
|
||||
let sdk_room = self.client.get_dm_room(&user_id).map(SdkRoom::Joined);
|
||||
let dm = sdk_room.map(|room| Arc::new(Room::new(room)));
|
||||
Ok(dm)
|
||||
}
|
||||
}
|
||||
|
||||
impl Client {
|
||||
|
||||
@@ -339,7 +339,8 @@ impl Client {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn get_dm_room(&self, user_id: &UserId) -> Option<room::Joined> {
|
||||
/// Get the existing DM room with the given user, if any.
|
||||
pub fn get_dm_room(&self, user_id: &UserId) -> Option<room::Joined> {
|
||||
let rooms = self.joined_rooms();
|
||||
|
||||
// Find the room we share with the `user_id` and only with `user_id`
|
||||
|
||||
Reference in New Issue
Block a user