Skip to content

Commit 76763a8

Browse files
authored
ffi: Add binding for get_dm_room
1 parent 72ae9dd commit 76763a8

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

bindings/matrix-sdk-ffi/src/client.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use std::sync::{Arc, RwLock};
33
use anyhow::{anyhow, Context};
44
use matrix_sdk::{
55
media::{MediaFileHandle as SdkMediaFileHandle, MediaFormat, MediaRequest, MediaThumbnailSize},
6+
room::Room as SdkRoom,
67
ruma::{
78
api::client::{
89
account::whoami,
@@ -497,6 +498,13 @@ impl Client {
497498
pub fn rooms(&self) -> Vec<Arc<Room>> {
498499
self.client.rooms().into_iter().map(|room| Arc::new(Room::new(room))).collect()
499500
}
501+
502+
pub fn get_dm_room(&self, user_id: String) -> Result<Option<Arc<Room>>, ClientError> {
503+
let user_id = UserId::parse(user_id)?;
504+
let sdk_room = self.client.get_dm_room(&user_id).map(SdkRoom::Joined);
505+
let dm = sdk_room.map(|room| Arc::new(Room::new(room)));
506+
Ok(dm)
507+
}
500508
}
501509

502510
impl Client {

crates/matrix-sdk/src/encryption/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,8 @@ impl Client {
339339
Ok(())
340340
}
341341

342-
fn get_dm_room(&self, user_id: &UserId) -> Option<room::Joined> {
342+
/// Get the existing DM room with the given user, if any.
343+
pub fn get_dm_room(&self, user_id: &UserId) -> Option<room::Joined> {
343344
let rooms = self.joined_rooms();
344345

345346
// Find the room we share with the `user_id` and only with `user_id`

0 commit comments

Comments
 (0)