From 7ac6ebfb7fb65eaeb58d4f163215d826719fcd95 Mon Sep 17 00:00:00 2001 From: Alfonso Grillo Date: Mon, 8 May 2023 17:30:47 +0200 Subject: [PATCH] Add invited and joined counts --- bindings/matrix-sdk-ffi/src/room.rs | 8 ++++++++ crates/matrix-sdk-base/src/rooms/normal.rs | 20 ++++++++++++++++++++ crates/matrix-sdk/src/room/common.rs | 6 ------ 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/bindings/matrix-sdk-ffi/src/room.rs b/bindings/matrix-sdk-ffi/src/room.rs index 277465fcb..dd6913126 100644 --- a/bindings/matrix-sdk-ffi/src/room.rs +++ b/bindings/matrix-sdk-ffi/src/room.rs @@ -456,6 +456,14 @@ impl Room { self.room.active_members_count() } + pub fn invited_members_count(&self) -> u64 { + self.room.invited_members_count() + } + + pub fn joined_members_count(&self) -> u64 { + self.room.joined_members_count() + } + /// Reports an event from the room. /// /// # Arguments diff --git a/crates/matrix-sdk-base/src/rooms/normal.rs b/crates/matrix-sdk-base/src/rooms/normal.rs index 9852efe97..1931a94c2 100644 --- a/crates/matrix-sdk-base/src/rooms/normal.rs +++ b/crates/matrix-sdk-base/src/rooms/normal.rs @@ -358,6 +358,16 @@ impl Room { self.inner.read().unwrap().active_members_count() } + /// Returns the number of members who have been invited to the room. + pub fn invited_members_count(&self) -> u64 { + self.inner.read().unwrap().invited_members_count() + } + + /// Returns the number of members who have joined the room. + pub fn joined_members_count(&self) -> u64 { + self.inner.read().unwrap().joined_members_count() + } + async fn calculate_name(&self) -> StoreResult { let summary = { let inner = self.inner.read().unwrap(); @@ -750,6 +760,16 @@ impl RoomInfo { self.summary.joined_member_count.saturating_add(self.summary.invited_member_count) } + /// The number of invited members in the room + pub fn invited_members_count(&self) -> u64 { + self.summary.invited_member_count + } + + /// The number of joined members in the room + pub fn joined_members_count(&self) -> u64 { + self.summary.joined_member_count + } + /// Get the canonical alias of this room. pub fn canonical_alias(&self) -> Option<&RoomAliasId> { self.base_info.canonical_alias.as_ref()?.as_original()?.content.alias.as_deref() diff --git a/crates/matrix-sdk/src/room/common.rs b/crates/matrix-sdk/src/room/common.rs index 1d1c43241..63c88026c 100644 --- a/crates/matrix-sdk/src/room/common.rs +++ b/crates/matrix-sdk/src/room/common.rs @@ -437,12 +437,6 @@ impl Common { self.members_no_sync(RoomMemberships::ACTIVE).await } - /// Returns the number of members who have joined or been invited to the - /// room. - pub fn active_members_count(&self) -> u64 { - self.inner.active_members_count() - } - /// Get active members for this room, includes invited, joined members. /// /// *Note*: This method will not fetch the members from the homeserver if