Merge branch '244-room-history'

master
Damir Jelić 2021-06-21 17:33:40 +02:00
commit 8f1d8eeca2
1 changed files with 17 additions and 0 deletions

View File

@ -7,11 +7,13 @@ use ruma::{
membership::{get_member_events, join_room_by_id, leave_room}, membership::{get_member_events, join_room_by_id, leave_room},
message::get_message_events, message::get_message_events,
}, },
events::room::history_visibility::HistoryVisibility,
UserId, UserId,
}; };
use crate::{ use crate::{
media::{MediaFormat, MediaRequest, MediaType}, media::{MediaFormat, MediaRequest, MediaType},
room::RoomType,
BaseRoom, Client, Result, RoomMember, BaseRoom, Client, Result, RoomMember,
}; };
@ -169,6 +171,10 @@ impl Common {
} }
async fn ensure_members(&self) -> Result<()> { async fn ensure_members(&self) -> Result<()> {
if !self.are_events_visible() {
return Ok(());
}
if !self.are_members_synced() { if !self.are_members_synced() {
self.request_members().await?; self.request_members().await?;
} }
@ -176,6 +182,17 @@ impl Common {
Ok(()) Ok(())
} }
fn are_events_visible(&self) -> bool {
if let RoomType::Invited = self.inner.room_type() {
return matches!(
self.inner.history_visibility(),
HistoryVisibility::WorldReadable | HistoryVisibility::Invited
);
}
true
}
/// Sync the member list with the server. /// Sync the member list with the server.
/// ///
/// This method will de-duplicate requests if it is called multiple times in /// This method will de-duplicate requests if it is called multiple times in