base: Handle the join rules, history visibility and guest access
parent
108d4ebffe
commit
e9d22c95a4
|
@ -2,7 +2,13 @@ mod members;
|
|||
mod normal;
|
||||
mod stripped;
|
||||
|
||||
use matrix_sdk_common::{events::room::create::CreateEventContent, identifiers::UserId};
|
||||
use matrix_sdk_common::{
|
||||
events::room::{
|
||||
create::CreateEventContent, guest_access::GuestAccess,
|
||||
history_visibility::HistoryVisibility, join_rules::JoinRule,
|
||||
},
|
||||
identifiers::UserId,
|
||||
};
|
||||
pub use normal::{Room, RoomInfo, RoomType};
|
||||
pub use stripped::{StrippedRoom, StrippedRoomInfo};
|
||||
|
||||
|
@ -118,15 +124,18 @@ impl Deref for InvitedRoom {
|
|||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
pub struct BaseRoomInfo {
|
||||
pub name: Option<String>,
|
||||
pub canonical_alias: Option<RoomAliasId>,
|
||||
pub dm_target: Option<UserId>,
|
||||
pub avatar_url: Option<String>,
|
||||
pub topic: Option<String>,
|
||||
pub encryption: Option<EncryptionEventContent>,
|
||||
pub tombstone: Option<TombstoneEventContent>,
|
||||
pub canonical_alias: Option<RoomAliasId>,
|
||||
pub create: Option<CreateEventContent>,
|
||||
pub dm_target: Option<UserId>,
|
||||
pub encryption: Option<EncryptionEventContent>,
|
||||
pub guest_access: GuestAccess,
|
||||
pub history_visibility: HistoryVisibility,
|
||||
pub join_rule: JoinRule,
|
||||
pub max_power_level: i64,
|
||||
pub name: Option<String>,
|
||||
pub tombstone: Option<TombstoneEventContent>,
|
||||
pub topic: Option<String>,
|
||||
}
|
||||
|
||||
impl BaseRoomInfo {
|
||||
|
@ -152,6 +161,18 @@ impl BaseRoomInfo {
|
|||
false
|
||||
}
|
||||
}
|
||||
AnyStateEventContent::RoomHistoryVisibility(h) => {
|
||||
self.history_visibility = h.history_visibility.clone();
|
||||
true
|
||||
}
|
||||
AnyStateEventContent::RoomGuestAccess(g) => {
|
||||
self.guest_access = g.guest_access.clone();
|
||||
true
|
||||
}
|
||||
AnyStateEventContent::RoomJoinRules(c) => {
|
||||
self.join_rule = c.join_rule.clone();
|
||||
true
|
||||
}
|
||||
AnyStateEventContent::RoomCanonicalAlias(a) => {
|
||||
self.canonical_alias = a.alias.clone();
|
||||
true
|
||||
|
@ -180,15 +201,18 @@ impl BaseRoomInfo {
|
|||
impl Default for BaseRoomInfo {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
name: None,
|
||||
canonical_alias: None,
|
||||
dm_target: None,
|
||||
avatar_url: None,
|
||||
topic: None,
|
||||
encryption: None,
|
||||
tombstone: None,
|
||||
max_power_level: 100,
|
||||
canonical_alias: None,
|
||||
create: None,
|
||||
dm_target: None,
|
||||
encryption: None,
|
||||
guest_access: GuestAccess::CanJoin,
|
||||
history_visibility: HistoryVisibility::WorldReadable,
|
||||
join_rule: JoinRule::Public,
|
||||
max_power_level: 100,
|
||||
name: None,
|
||||
tombstone: None,
|
||||
topic: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,11 @@ use futures::{
|
|||
use matrix_sdk_common::{
|
||||
api::r0::sync::sync_events::RoomSummary as RumaSummary,
|
||||
events::{
|
||||
room::{encryption::EncryptionEventContent, tombstone::TombstoneEventContent},
|
||||
room::{
|
||||
create::CreateEventContent, encryption::EncryptionEventContent,
|
||||
guest_access::GuestAccess, history_visibility::HistoryVisibility, join_rules::JoinRule,
|
||||
tombstone::TombstoneEventContent,
|
||||
},
|
||||
AnySyncStateEvent, EventType,
|
||||
},
|
||||
identifiers::{RoomAliasId, RoomId, UserId},
|
||||
|
@ -117,14 +121,18 @@ impl Room {
|
|||
self.inner.read().unwrap().last_prev_batch.clone()
|
||||
}
|
||||
|
||||
pub fn name(&self) -> Option<String> {
|
||||
self.inner.read().unwrap().base_info.name.clone()
|
||||
pub fn avatar_url(&self) -> Option<String> {
|
||||
self.inner.read().unwrap().base_info.avatar_url.clone()
|
||||
}
|
||||
|
||||
pub fn canonical_alias(&self) -> Option<RoomAliasId> {
|
||||
self.inner.read().unwrap().base_info.canonical_alias.clone()
|
||||
}
|
||||
|
||||
pub fn create_content(&self) -> Option<CreateEventContent> {
|
||||
self.inner.read().unwrap().base_info.create.clone()
|
||||
}
|
||||
|
||||
pub fn is_direct(&self) -> bool {
|
||||
self.inner.read().unwrap().base_info.dm_target.is_some()
|
||||
}
|
||||
|
@ -133,14 +141,6 @@ impl Room {
|
|||
self.inner.read().unwrap().base_info.dm_target.clone()
|
||||
}
|
||||
|
||||
pub fn avatar_url(&self) -> Option<String> {
|
||||
self.inner.read().unwrap().base_info.avatar_url.clone()
|
||||
}
|
||||
|
||||
pub fn topic(&self) -> Option<String> {
|
||||
self.inner.read().unwrap().base_info.topic.clone()
|
||||
}
|
||||
|
||||
pub fn is_encrypted(&self) -> bool {
|
||||
self.inner.read().unwrap().is_encrypted()
|
||||
}
|
||||
|
@ -149,6 +149,31 @@ impl Room {
|
|||
self.inner.read().unwrap().base_info.encryption.clone()
|
||||
}
|
||||
|
||||
pub fn guest_access(&self) -> GuestAccess {
|
||||
self.inner.read().unwrap().base_info.guest_access.clone()
|
||||
}
|
||||
|
||||
pub fn history_visibility(&self) -> HistoryVisibility {
|
||||
self.inner
|
||||
.read()
|
||||
.unwrap()
|
||||
.base_info
|
||||
.history_visibility
|
||||
.clone()
|
||||
}
|
||||
|
||||
pub fn joine_rules(&self) -> JoinRule {
|
||||
self.inner.read().unwrap().base_info.join_rule.clone()
|
||||
}
|
||||
|
||||
pub fn max_power_level(&self) -> i64 {
|
||||
self.inner.read().unwrap().base_info.max_power_level
|
||||
}
|
||||
|
||||
pub fn name(&self) -> Option<String> {
|
||||
self.inner.read().unwrap().base_info.name.clone()
|
||||
}
|
||||
|
||||
pub fn is_tombstoned(&self) -> bool {
|
||||
self.inner.read().unwrap().base_info.tombstone.is_some()
|
||||
}
|
||||
|
@ -157,8 +182,8 @@ impl Room {
|
|||
self.inner.read().unwrap().base_info.tombstone.clone()
|
||||
}
|
||||
|
||||
pub fn max_power_level(&self) -> i64 {
|
||||
self.inner.read().unwrap().base_info.max_power_level
|
||||
pub fn topic(&self) -> Option<String> {
|
||||
self.inner.read().unwrap().base_info.topic.clone()
|
||||
}
|
||||
|
||||
pub async fn display_name(&self) -> String {
|
||||
|
|
Loading…
Reference in New Issue