Add invited and joined counts

This commit is contained in:
Alfonso Grillo
2023-05-08 17:30:47 +02:00
committed by Damir Jelić
parent 43b28e6087
commit 7ac6ebfb7f
3 changed files with 28 additions and 6 deletions

View File

@@ -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

View File

@@ -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<DisplayName> {
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()

View File

@@ -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