diff --git a/crates/matrix-sdk-base/src/client.rs b/crates/matrix-sdk-base/src/client.rs index 36485c13e2..2ba2e133f3 100644 --- a/crates/matrix-sdk-base/src/client.rs +++ b/crates/matrix-sdk-base/src/client.rs @@ -1739,7 +1739,7 @@ mod tests { use super::BaseClient; use crate::{ - store::StateStoreExt, test_utils::logged_in_base_client, DisplayName, RoomState, + store::StateStoreExt, test_utils::logged_in_base_client, RoomDisplayName, RoomState, SessionMeta, }; @@ -1871,7 +1871,7 @@ mod tests { assert_eq!(room.state(), RoomState::Invited); assert_eq!( room.compute_display_name().await.expect("fetching display name failed"), - DisplayName::Calculated("Kyra".to_owned()) + RoomDisplayName::Calculated("Kyra".to_owned()) ); } diff --git a/crates/matrix-sdk-base/src/lib.rs b/crates/matrix-sdk-base/src/lib.rs index 611305a59e..f884448c7a 100644 --- a/crates/matrix-sdk-base/src/lib.rs +++ b/crates/matrix-sdk-base/src/lib.rs @@ -56,7 +56,7 @@ pub use http; pub use matrix_sdk_crypto as crypto; pub use once_cell; pub use rooms::{ - DisplayName, Room, RoomCreateWithCreatorEventContent, RoomHero, RoomInfo, + Room, RoomCreateWithCreatorEventContent, RoomDisplayName, RoomHero, RoomInfo, RoomInfoNotableUpdate, RoomInfoNotableUpdateReasons, RoomMember, RoomMemberships, RoomState, RoomStateFilter, }; diff --git a/crates/matrix-sdk-base/src/rooms/mod.rs b/crates/matrix-sdk-base/src/rooms/mod.rs index fac5b164f9..c9cb43cfd9 100644 --- a/crates/matrix-sdk-base/src/rooms/mod.rs +++ b/crates/matrix-sdk-base/src/rooms/mod.rs @@ -49,7 +49,7 @@ use crate::MinimalStateEvent; /// The name of the room, either from the metadata or calculated /// according to [matrix specification](https://matrix.org/docs/spec/client_server/latest#calculating-the-display-name-for-a-room) #[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] -pub enum DisplayName { +pub enum RoomDisplayName { /// The room has been named explicitly as Named(String), /// The room has a canonical alias that should be used @@ -64,14 +64,16 @@ pub enum DisplayName { Empty, } -impl fmt::Display for DisplayName { +impl fmt::Display for RoomDisplayName { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - DisplayName::Named(s) | DisplayName::Calculated(s) | DisplayName::Aliased(s) => { + RoomDisplayName::Named(s) + | RoomDisplayName::Calculated(s) + | RoomDisplayName::Aliased(s) => { write!(f, "{s}") } - DisplayName::EmptyWas(s) => write!(f, "Empty Room (was {s})"), - DisplayName::Empty => write!(f, "Empty Room"), + RoomDisplayName::EmptyWas(s) => write!(f, "Empty Room (was {s})"), + RoomDisplayName::Empty => write!(f, "Empty Room"), } } } diff --git a/crates/matrix-sdk-base/src/rooms/normal.rs b/crates/matrix-sdk-base/src/rooms/normal.rs index 7181d4d482..49fad5cfcc 100644 --- a/crates/matrix-sdk-base/src/rooms/normal.rs +++ b/crates/matrix-sdk-base/src/rooms/normal.rs @@ -61,7 +61,7 @@ use tokio::sync::broadcast; use tracing::{debug, field::debug, info, instrument, warn}; use super::{ - members::MemberRoomInfo, BaseRoomInfo, DisplayName, RoomCreateWithCreatorEventContent, + members::MemberRoomInfo, BaseRoomInfo, RoomCreateWithCreatorEventContent, RoomDisplayName, RoomMember, RoomNotableTags, }; #[cfg(feature = "experimental-sliding-sync")] @@ -572,8 +572,8 @@ impl Room { /// [`Self::cached_display_name`]. /// /// [spec]: - pub async fn compute_display_name(&self) -> StoreResult { - let update_cache = |new_val: DisplayName| { + pub async fn compute_display_name(&self) -> StoreResult { + let update_cache = |new_val: RoomDisplayName| { self.inner.update_if(|info| { if info.cached_display_name.as_ref() != Some(&new_val) { info.cached_display_name = Some(new_val.clone()); @@ -591,13 +591,13 @@ impl Room { if let Some(name) = inner.name() { let name = name.trim().to_owned(); drop(inner); // drop the lock on `self.inner` to avoid deadlocking in `update_cache`. - return Ok(update_cache(DisplayName::Named(name))); + return Ok(update_cache(RoomDisplayName::Named(name))); } if let Some(alias) = inner.canonical_alias() { let alias = alias.alias().trim().to_owned(); drop(inner); // See above comment. - return Ok(update_cache(DisplayName::Aliased(alias))); + return Ok(update_cache(RoomDisplayName::Aliased(alias))); } inner.summary.clone() @@ -703,7 +703,7 @@ impl Room { /// /// This cache is refilled every time we call /// [`Self::compute_display_name`]. - pub fn cached_display_name(&self) -> Option { + pub fn cached_display_name(&self) -> Option { self.inner.read().cached_display_name.clone() } @@ -1103,7 +1103,7 @@ pub struct RoomInfo { /// Filled by calling [`Room::compute_display_name`]. It's automatically /// filled at start when creating a room, or on every successful sync. #[serde(default, skip_serializing_if = "Option::is_none")] - pub(crate) cached_display_name: Option, + pub(crate) cached_display_name: Option, /// Cached user defined notification mode. #[serde(default, skip_serializing_if = "Option::is_none")] @@ -1767,7 +1767,10 @@ impl RoomStateFilter { /// Calculate room name according to step 3 of the [naming algorithm]. /// /// [naming algorithm]: https://spec.matrix.org/latest/client-server-api/#calculating-the-display-name-for-a-room -fn compute_display_name_from_heroes(num_joined_invited: u64, mut heroes: Vec<&str>) -> DisplayName { +fn compute_display_name_from_heroes( + num_joined_invited: u64, + mut heroes: Vec<&str>, +) -> RoomDisplayName { let num_heroes = heroes.len() as u64; let num_joined_invited_except_self = num_joined_invited.saturating_sub(1); @@ -1789,12 +1792,12 @@ fn compute_display_name_from_heroes(num_joined_invited: u64, mut heroes: Vec<&st // User is alone. if num_joined_invited <= 1 { if names.is_empty() { - DisplayName::Empty + RoomDisplayName::Empty } else { - DisplayName::EmptyWas(names) + RoomDisplayName::EmptyWas(names) } } else { - DisplayName::Calculated(names) + RoomDisplayName::Calculated(names) } } @@ -1851,7 +1854,7 @@ mod tests { use crate::{ rooms::RoomNotableTags, store::{IntoStateStore, MemoryStore, StateChanges, StateStore}, - BaseClient, DisplayName, MinimalStateEvent, OriginalMinimalStateEvent, + BaseClient, MinimalStateEvent, OriginalMinimalStateEvent, RoomDisplayName, RoomInfoNotableUpdateReasons, SessionMeta, }; @@ -2126,7 +2129,7 @@ mod tests { assert_eq!( info.cached_display_name.as_ref(), - Some(&DisplayName::Calculated("lol".to_owned())), + Some(&RoomDisplayName::Calculated("lol".to_owned())), ); assert_eq!( info.cached_user_defined_notification_mode.as_ref(), @@ -2331,7 +2334,7 @@ mod tests { #[async_test] async fn test_display_name_for_joined_room_is_empty_if_no_info() { let (_, room) = make_room_test_helper(RoomState::Joined); - assert_eq!(room.compute_display_name().await.unwrap(), DisplayName::Empty); + assert_eq!(room.compute_display_name().await.unwrap(), RoomDisplayName::Empty); } #[async_test] @@ -2341,7 +2344,7 @@ mod tests { .update(|info| info.base_info.canonical_alias = Some(make_canonical_alias_event())); assert_eq!( room.compute_display_name().await.unwrap(), - DisplayName::Aliased("test".to_owned()) + RoomDisplayName::Aliased("test".to_owned()) ); } @@ -2352,20 +2355,20 @@ mod tests { .update(|info| info.base_info.canonical_alias = Some(make_canonical_alias_event())); assert_eq!( room.compute_display_name().await.unwrap(), - DisplayName::Aliased("test".to_owned()) + RoomDisplayName::Aliased("test".to_owned()) ); room.inner.update(|info| info.base_info.name = Some(make_name_event())); // Display name wasn't cached when we asked for it above, and name overrides assert_eq!( room.compute_display_name().await.unwrap(), - DisplayName::Named("Test Room".to_owned()) + RoomDisplayName::Named("Test Room".to_owned()) ); } #[async_test] async fn test_display_name_for_invited_room_is_empty_if_no_info() { let (_, room) = make_room_test_helper(RoomState::Invited); - assert_eq!(room.compute_display_name().await.unwrap(), DisplayName::Empty); + assert_eq!(room.compute_display_name().await.unwrap(), RoomDisplayName::Empty); } #[async_test] @@ -2378,7 +2381,7 @@ mod tests { }); room.inner.update(|info| info.base_info.name = Some(room_name)); - assert_eq!(room.compute_display_name().await.unwrap(), DisplayName::Empty); + assert_eq!(room.compute_display_name().await.unwrap(), RoomDisplayName::Empty); } #[async_test] @@ -2388,7 +2391,7 @@ mod tests { .update(|info| info.base_info.canonical_alias = Some(make_canonical_alias_event())); assert_eq!( room.compute_display_name().await.unwrap(), - DisplayName::Aliased("test".to_owned()) + RoomDisplayName::Aliased("test".to_owned()) ); } @@ -2399,13 +2402,13 @@ mod tests { .update(|info| info.base_info.canonical_alias = Some(make_canonical_alias_event())); assert_eq!( room.compute_display_name().await.unwrap(), - DisplayName::Aliased("test".to_owned()) + RoomDisplayName::Aliased("test".to_owned()) ); room.inner.update(|info| info.base_info.name = Some(make_name_event())); // Display name wasn't cached when we asked for it above, and name overrides assert_eq!( room.compute_display_name().await.unwrap(), - DisplayName::Named("Test Room".to_owned()) + RoomDisplayName::Named("Test Room".to_owned()) ); } @@ -2447,7 +2450,7 @@ mod tests { room.inner.update_if(|info| info.update_from_ruma_summary(&summary)); assert_eq!( room.compute_display_name().await.unwrap(), - DisplayName::Calculated("Matthew".to_owned()) + RoomDisplayName::Calculated("Matthew".to_owned()) ); } @@ -2469,7 +2472,7 @@ mod tests { assert_eq!( room.compute_display_name().await.unwrap(), - DisplayName::Calculated("Matthew".to_owned()) + RoomDisplayName::Calculated("Matthew".to_owned()) ); } @@ -2499,7 +2502,7 @@ mod tests { room.inner.update_if(|info| info.update_from_ruma_summary(&summary)); assert_eq!( room.compute_display_name().await.unwrap(), - DisplayName::Calculated("Matthew".to_owned()) + RoomDisplayName::Calculated("Matthew".to_owned()) ); } @@ -2524,7 +2527,7 @@ mod tests { assert_eq!( room.compute_display_name().await.unwrap(), - DisplayName::Calculated("Matthew".to_owned()) + RoomDisplayName::Calculated("Matthew".to_owned()) ); } @@ -2579,7 +2582,7 @@ mod tests { assert_eq!( room.compute_display_name().await.unwrap(), - DisplayName::Calculated("Bob, Carol, Denis, Erica, and 3 others".to_owned()) + RoomDisplayName::Calculated("Bob, Carol, Denis, Erica, and 3 others".to_owned()) ); } @@ -2628,7 +2631,7 @@ mod tests { assert_eq!( room.compute_display_name().await.unwrap(), - DisplayName::Calculated("Alice, Bob, Carol, Denis, Erica, and 2 others".to_owned()) + RoomDisplayName::Calculated("Alice, Bob, Carol, Denis, Erica, and 2 others".to_owned()) ); } @@ -2658,7 +2661,7 @@ mod tests { room.inner.update_if(|info| info.update_from_ruma_summary(&summary)); assert_eq!( room.compute_display_name().await.unwrap(), - DisplayName::EmptyWas("Matthew".to_owned()) + RoomDisplayName::EmptyWas("Matthew".to_owned()) ); } @@ -3054,34 +3057,34 @@ mod tests { #[test] fn test_calculate_room_name() { let mut actual = compute_display_name_from_heroes(2, vec!["a"]); - assert_eq!(DisplayName::Calculated("a".to_owned()), actual); + assert_eq!(RoomDisplayName::Calculated("a".to_owned()), actual); actual = compute_display_name_from_heroes(3, vec!["a", "b"]); - assert_eq!(DisplayName::Calculated("a, b".to_owned()), actual); + assert_eq!(RoomDisplayName::Calculated("a, b".to_owned()), actual); actual = compute_display_name_from_heroes(4, vec!["a", "b", "c"]); - assert_eq!(DisplayName::Calculated("a, b, c".to_owned()), actual); + assert_eq!(RoomDisplayName::Calculated("a, b, c".to_owned()), actual); actual = compute_display_name_from_heroes(5, vec!["a", "b", "c"]); - assert_eq!(DisplayName::Calculated("a, b, c, and 2 others".to_owned()), actual); + assert_eq!(RoomDisplayName::Calculated("a, b, c, and 2 others".to_owned()), actual); actual = compute_display_name_from_heroes(5, vec![]); - assert_eq!(DisplayName::Calculated("5 people".to_owned()), actual); + assert_eq!(RoomDisplayName::Calculated("5 people".to_owned()), actual); actual = compute_display_name_from_heroes(0, vec![]); - assert_eq!(DisplayName::Empty, actual); + assert_eq!(RoomDisplayName::Empty, actual); actual = compute_display_name_from_heroes(1, vec![]); - assert_eq!(DisplayName::Empty, actual); + assert_eq!(RoomDisplayName::Empty, actual); actual = compute_display_name_from_heroes(1, vec!["a"]); - assert_eq!(DisplayName::EmptyWas("a".to_owned()), actual); + assert_eq!(RoomDisplayName::EmptyWas("a".to_owned()), actual); actual = compute_display_name_from_heroes(1, vec!["a", "b"]); - assert_eq!(DisplayName::EmptyWas("a, b".to_owned()), actual); + assert_eq!(RoomDisplayName::EmptyWas("a, b".to_owned()), actual); actual = compute_display_name_from_heroes(1, vec!["a", "b", "c"]); - assert_eq!(DisplayName::EmptyWas("a, b, c".to_owned()), actual); + assert_eq!(RoomDisplayName::EmptyWas("a, b, c".to_owned()), actual); } #[test] diff --git a/crates/matrix-sdk-base/src/store/ambiguity_map.rs b/crates/matrix-sdk-base/src/store/ambiguity_map.rs index 907ee7c3e4..228b4da47d 100644 --- a/crates/matrix-sdk-base/src/store/ambiguity_map.rs +++ b/crates/matrix-sdk-base/src/store/ambiguity_map.rs @@ -39,13 +39,16 @@ pub(crate) struct AmbiguityCache { pub changes: BTreeMap>, } -#[derive(Debug)] -struct AmbiguityMap { +/// A map of users that use a certain display name. +#[derive(Debug, Clone)] +struct DisplayNameUsers { display_name: String, users: BTreeSet, } -impl AmbiguityMap { +impl DisplayNameUsers { + /// Remove the given [`UserId`] from the map, marking that the [`UserId`] + /// doesn't use the display name anymore. fn remove(&mut self, user_id: &UserId) -> Option { self.users.remove(user_id); @@ -56,6 +59,8 @@ impl AmbiguityMap { } } + /// Add the given [`UserId`] from the map, marking that the [`UserId`] + /// is using the display name. fn add(&mut self, user_id: OwnedUserId) -> Option { let ambiguous_user = if self.user_count() == 1 { self.users.iter().next().cloned() } else { None }; @@ -65,10 +70,12 @@ impl AmbiguityMap { ambiguous_user } + /// How many users are using this display name. fn user_count(&self) -> usize { self.users.len() } + /// Is the display name considered to be ambiguous. fn is_ambiguous(&self) -> bool { self.user_count() > 1 } @@ -85,15 +92,14 @@ impl AmbiguityCache { room_id: &RoomId, member_event: &SyncRoomMemberEvent, ) -> Result<()> { - // Synapse seems to have a bug where it puts the same event into the - // state and the timeline sometimes. + // Synapse seems to have a bug where it puts the same event into the state and + // the timeline sometimes. // - // Since our state, e.g. the old display name, already ended up inside - // the state changes and we're pulling stuff out of the cache if it's - // there calculating this twice for the same event will result in an - // incorrect AmbiguityChange overwriting the correct one. In other - // words, this method is not idempotent so we make it by ignoring - // duplicate events. + // Since our state, e.g. the old display name, already ended up inside the state + // changes and we're pulling stuff out of the cache if it's there calculating + // this twice for the same event will result in an incorrect AmbiguityChange + // overwriting the correct one. In other words, this method is not idempotent so + // we make it by ignoring duplicate events. if self.changes.get(room_id).is_some_and(|c| c.contains_key(member_event.event_id())) { return Ok(()); } @@ -105,6 +111,8 @@ impl AmbiguityCache { _ => false, }; + // If the user's display name didn't change, then there's nothing more to + // calculate here. if display_names_same { return Ok(()); } @@ -134,17 +142,17 @@ impl AmbiguityCache { fn update( &mut self, room_id: &RoomId, - old_map: Option, - new_map: Option, + old_map: Option, + new_map: Option, ) { let entry = self.cache.entry(room_id.to_owned()).or_default(); if let Some(old) = old_map { - entry.insert(old.display_name, old.users); + entry.insert(old.display_name.clone(), old.users); } if let Some(new) = new_map { - entry.insert(new.display_name, new.users); + entry.insert(new.display_name.clone(), new.users); } } @@ -152,57 +160,76 @@ impl AmbiguityCache { self.changes.entry(room_id.to_owned()).or_default().insert(event_id, change); } - async fn get( - &mut self, + async fn get_old_display_name( + &self, changes: &StateChanges, room_id: &RoomId, - member_event: &SyncRoomMemberEvent, - ) -> Result<(Option, Option)> { + new_event: &SyncRoomMemberEvent, + ) -> Result> { use MembershipState::*; let old_event = if let Some(m) = changes.state.get(room_id).and_then(|events| { - events.get(&StateEventType::RoomMember)?.get(member_event.state_key().as_str()) + events.get(&StateEventType::RoomMember)?.get(new_event.state_key().as_str()) }) { Some(RawMemberEvent::Sync(m.clone().cast())) } else { - self.store.get_member_event(room_id, member_event.state_key()).await? + self.store.get_member_event(room_id, new_event.state_key()).await? }; - // FIXME: Use let chains once stable - let old_display_name = if let Some(Ok(event)) = old_event.map(|r| r.deserialize()) { - if matches!(event.membership(), Join | Invite) { - let display_name = if let Some(d) = changes.profiles.get(room_id).and_then(|p| { - p.get(member_event.state_key())?.as_original()?.content.displayname.as_deref() - }) { - Some(d.to_owned()) - } else if let Some(d) = self - .store - .get_profile(room_id, member_event.state_key()) - .await? - .and_then(|p| p.into_original()?.content.displayname) - { - Some(d) - } else { - event.original_content().and_then(|c| c.displayname.clone()) - }; - - Some(display_name.unwrap_or_else(|| event.user_id().localpart().to_owned())) + let Some(Ok(old_event)) = old_event.map(|r| r.deserialize()) else { return Ok(None) }; + + if matches!(old_event.membership(), Join | Invite) { + let display_name = if let Some(d) = changes.profiles.get(room_id).and_then(|p| { + p.get(new_event.state_key())?.as_original()?.content.displayname.as_deref() + }) { + Some(d.to_owned()) + } else if let Some(d) = self + .store + .get_profile(room_id, new_event.state_key()) + .await? + .and_then(|p| p.into_original()?.content.displayname) + { + Some(d) } else { - None - } + old_event.original_content().and_then(|c| c.displayname.clone()) + }; + + Ok(Some(display_name.unwrap_or_else(|| old_event.user_id().localpart().to_owned()))) } else { - None - }; + Ok(None) + } + } + + async fn get_users_with_display_name( + &mut self, + room_id: &RoomId, + display_name: &str, + ) -> Result { + Ok(if let Some(u) = self.cache.entry(room_id.to_owned()).or_default().get(display_name) { + DisplayNameUsers { display_name: display_name.to_owned(), users: u.clone() } + } else { + let users_with_display_name = + self.store.get_users_with_display_name(room_id, display_name).await?; + + DisplayNameUsers { + display_name: display_name.to_owned(), + users: users_with_display_name, + } + }) + } + + async fn get( + &mut self, + changes: &StateChanges, + room_id: &RoomId, + member_event: &SyncRoomMemberEvent, + ) -> Result<(Option, Option)> { + use MembershipState::*; + + let old_display_name = self.get_old_display_name(changes, room_id, member_event).await?; let old_map = if let Some(old_name) = old_display_name.as_deref() { - let old_display_name_map = - if let Some(u) = self.cache.entry(room_id.to_owned()).or_default().get(old_name) { - u.clone() - } else { - self.store.get_users_with_display_name(room_id, old_name).await? - }; - - Some(AmbiguityMap { display_name: old_name.to_owned(), users: old_display_name_map }) + Some(self.get_users_with_display_name(room_id, old_name).await?) } else { None }; @@ -213,9 +240,8 @@ impl AmbiguityCache { .and_then(|ev| ev.content.displayname.as_deref()) .unwrap_or_else(|| member_event.state_key().localpart()); - // We don't allow other users to set the display name, so if we - // have a more trusted version of the display - // name use that. + // We don't allow other users to set the display name, so if we have a more + // trusted version of the display name use that. let new_display_name = if member_event.sender().as_str() == member_event.state_key() { new } else if let Some(old) = old_display_name.as_deref() { @@ -224,18 +250,7 @@ impl AmbiguityCache { new }; - let new_display_name_map = if let Some(u) = - self.cache.entry(room_id.to_owned()).or_default().get(new_display_name) - { - u.clone() - } else { - self.store.get_users_with_display_name(room_id, new_display_name).await? - }; - - Some(AmbiguityMap { - display_name: new_display_name.to_owned(), - users: new_display_name_map, - }) + Some(self.get_users_with_display_name(room_id, new_display_name).await?) } else { None }; diff --git a/crates/matrix-sdk/src/lib.rs b/crates/matrix-sdk/src/lib.rs index 758f25d43b..370061fa8d 100644 --- a/crates/matrix-sdk/src/lib.rs +++ b/crates/matrix-sdk/src/lib.rs @@ -25,9 +25,10 @@ pub use matrix_sdk_base::crypto; pub use matrix_sdk_base::{ deserialized_responses, store::{DynStateStore, MemoryStore, StateStoreExt}, - ComposerDraft, ComposerDraftType, DisplayName, QueueWedgeError, Room as BaseRoom, - RoomCreateWithCreatorEventContent, RoomHero, RoomInfo, RoomMember as BaseRoomMember, - RoomMemberships, RoomState, SessionMeta, StateChanges, StateStore, StoreError, + ComposerDraft, ComposerDraftType, QueueWedgeError, Room as BaseRoom, + RoomCreateWithCreatorEventContent, RoomDisplayName, RoomHero, RoomInfo, + RoomMember as BaseRoomMember, RoomMemberships, RoomState, SessionMeta, StateChanges, + StateStore, StoreError, }; pub use matrix_sdk_common::*; pub use reqwest; diff --git a/crates/matrix-sdk/tests/integration/room/common.rs b/crates/matrix-sdk/tests/integration/room/common.rs index f742ee3bfe..33efb813ea 100644 --- a/crates/matrix-sdk/tests/integration/room/common.rs +++ b/crates/matrix-sdk/tests/integration/room/common.rs @@ -3,7 +3,7 @@ use std::{iter, time::Duration}; use assert_matches2::{assert_let, assert_matches}; use js_int::uint; use matrix_sdk::{ - config::SyncSettings, room::RoomMember, test_utils::events::EventFactory, DisplayName, + config::SyncSettings, room::RoomMember, test_utils::events::EventFactory, RoomDisplayName, RoomMemberships, }; use matrix_sdk_test::{ @@ -66,7 +66,7 @@ async fn test_calculate_room_names_from_summary() { let room = client.get_room(&DEFAULT_TEST_ROOM_ID).unwrap(); assert_eq!( - DisplayName::Calculated("example2".to_owned()), + RoomDisplayName::Calculated("example2".to_owned()), room.compute_display_name().await.unwrap() ); } @@ -86,7 +86,7 @@ async fn test_room_names() { let room = client.get_room(&DEFAULT_TEST_ROOM_ID).unwrap(); assert_eq!( - DisplayName::Aliased("tutorial".to_owned()), + RoomDisplayName::Aliased("tutorial".to_owned()), room.compute_display_name().await.unwrap() ); @@ -100,7 +100,7 @@ async fn test_room_names() { let invited_room = client.get_room(room_id!("!696r7674:example.com")).unwrap(); assert_eq!( - DisplayName::Named("My Room Name".to_owned()), + RoomDisplayName::Named("My Room Name".to_owned()), invited_room.compute_display_name().await.unwrap() ); @@ -136,7 +136,7 @@ async fn test_room_names() { let room = client.get_room(room_id).unwrap(); assert_eq!( - DisplayName::Calculated( + RoomDisplayName::Calculated( "user_0, user_1, user_10, user_11, user_12, and 10 others".to_owned() ), room.compute_display_name().await.unwrap() @@ -186,7 +186,7 @@ async fn test_room_names() { let room = client.get_room(room_id).unwrap(); assert_eq!( - DisplayName::Calculated("Bob, example1".to_owned()), + RoomDisplayName::Calculated("Bob, example1".to_owned()), room.compute_display_name().await.unwrap() ); @@ -206,7 +206,7 @@ async fn test_room_names() { let room = client.get_room(room_id).unwrap(); assert_eq!( - DisplayName::EmptyWas("user_0, user_1, user_2".to_owned()), + RoomDisplayName::EmptyWas("user_0, user_1, user_2".to_owned()), room.compute_display_name().await.unwrap() ); }