base: Don't mark all the room methods as public.

master
Damir Jelić 2021-01-04 12:26:13 +01:00
parent 83b850d8f9
commit 4afc6b2567
2 changed files with 8 additions and 12 deletions

View File

@ -2899,7 +2899,7 @@ mod test {
let room = client let room = client
.get_joined_room(&room_id!("!SVkFJHzfwvuaIEawgC:localhost")) .get_joined_room(&room_id!("!SVkFJHzfwvuaIEawgC:localhost"))
.unwrap(); .unwrap();
let members: Vec<RoomMember> = room.get_active_members().await.collect().await; let members: Vec<RoomMember> = room.active_members().await.collect().await;
assert_eq!(1, members.len()); assert_eq!(1, members.len());
// assert!(room.power_levels.is_some()) // assert!(room.power_levels.is_some())

View File

@ -63,7 +63,7 @@ pub enum RoomType {
} }
impl Room { impl Room {
pub fn new( pub(crate) fn new(
own_user_id: &UserId, own_user_id: &UserId,
store: SledStore, store: SledStore,
room_id: &RoomId, room_id: &RoomId,
@ -84,7 +84,7 @@ impl Room {
Self::restore(own_user_id, store, room_info) Self::restore(own_user_id, store, room_info)
} }
pub fn restore(own_user_id: &UserId, store: SledStore, room_info: RoomInfo) -> Self { pub(crate) fn restore(own_user_id: &UserId, store: SledStore, room_info: RoomInfo) -> Self {
Self { Self {
own_user_id: Arc::new(own_user_id.clone()), own_user_id: Arc::new(own_user_id.clone()),
room_id: room_info.room_id.clone(), room_id: room_info.room_id.clone(),
@ -165,17 +165,17 @@ impl Room {
self.calculate_name().await self.calculate_name().await
} }
pub async fn get_joined_user_ids(&self) -> impl Stream<Item = UserId> { pub async fn joined_user_ids(&self) -> impl Stream<Item = UserId> {
self.store.get_joined_user_ids(self.room_id()).await self.store.get_joined_user_ids(self.room_id()).await
} }
pub async fn get_joined_members(&self) -> impl Stream<Item = RoomMember> + '_ { pub async fn joined_members(&self) -> impl Stream<Item = RoomMember> + '_ {
let joined = self.store.get_joined_user_ids(self.room_id()).await; let joined = self.store.get_joined_user_ids(self.room_id()).await;
joined.filter_map(move |u| async move { self.get_member(&u).await }) joined.filter_map(move |u| async move { self.get_member(&u).await })
} }
pub async fn get_active_members(&self) -> impl Stream<Item = RoomMember> + '_ { pub async fn active_members(&self) -> impl Stream<Item = RoomMember> + '_ {
let joined = self.store.get_joined_user_ids(self.room_id()).await; let joined = self.store.get_joined_user_ids(self.room_id()).await;
let invited = self.store.get_invited_user_ids(self.room_id()).await; let invited = self.store.get_invited_user_ids(self.room_id()).await;
@ -235,7 +235,7 @@ impl Room {
names.sort(); names.sort();
names.join(", ") names.join(", ")
} else if heroes_count >= invited_joined { } else if heroes_count >= invited_joined {
let members = self.get_active_members().await; let members = self.active_members().await;
let mut names = members let mut names = members
.filter(|m| future::ready(is_own_member(m))) .filter(|m| future::ready(is_own_member(m)))
@ -251,7 +251,7 @@ impl Room {
names.sort(); names.sort();
names.join(", ") names.join(", ")
} else if heroes_count < invited_joined && invited + joined > 1 { } else if heroes_count < invited_joined && invited + joined > 1 {
let members = self.get_active_members().await; let members = self.active_members().await;
let mut names = members let mut names = members
.filter(|m| future::ready(is_own_member(m))) .filter(|m| future::ready(is_own_member(m)))
@ -278,10 +278,6 @@ impl Room {
(*self.inner.read().unwrap()).clone() (*self.inner.read().unwrap()).clone()
} }
pub async fn joined_user_ids(&self) -> impl Stream<Item = UserId> {
self.store.get_joined_user_ids(&self.room_id).await
}
pub fn update_summary(&self, summary: RoomInfo) { pub fn update_summary(&self, summary: RoomInfo) {
let mut inner = self.inner.write().unwrap(); let mut inner = self.inner.write().unwrap();
*inner = summary; *inner = summary;