Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions crates/matrix-sdk-base/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,7 @@ pub use store::{
QueueWedgeError, StateChanges, StateStore, StateStoreDataKey, StateStoreDataValue, StoreError,
ThreadSubscriptionCatchupToken,
};
pub use utils::{
MinimalRoomMemberEvent, MinimalStateEvent, OriginalMinimalStateEvent,
RawSyncStateEventWithKeys, RedactedMinimalStateEvent,
};
pub use utils::{MinimalRoomMemberEvent, MinimalStateEvent, RawSyncStateEventWithKeys};

#[cfg(test)]
matrix_sdk_test_utils::init_tracing_for_tests!();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ pub fn is_tombstone_event_valid(
.state_changes
.room_infos
.get(&successor_room_id)
.and_then(|room_info| Some(room_info.tombstone()?.replacement_room.clone()))
.and_then(|room_info| room_info.tombstone()?.replacement_room.clone())
.or_else(|| {
state_store
.room(&successor_room_id)
Expand Down
15 changes: 12 additions & 3 deletions crates/matrix-sdk-base/src/room/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ use matrix_sdk_common::ROOM_VERSION_RULES_FALLBACK;
use ruma::{
OwnedUserId, RoomVersionId, assign,
events::{
EmptyStateKey, RedactContent, RedactedStateEventContent, StateEventType,
EmptyStateKey, PossiblyRedactedStateEventContent, RedactContent, RedactedStateEventContent,
StateEventContent, StateEventType, StaticEventContent,
macros::EventContent,
room::create::{PreviousRoom, RoomCreateEventContent},
},
Expand Down Expand Up @@ -135,10 +136,10 @@ impl RoomCreateWithCreatorEventContent {
pub type RedactedRoomCreateWithCreatorEventContent = RoomCreateWithCreatorEventContent;

impl RedactedStateEventContent for RedactedRoomCreateWithCreatorEventContent {
type StateKey = EmptyStateKey;
type StateKey = <RoomCreateWithCreatorEventContent as StateEventContent>::StateKey;

fn event_type(&self) -> StateEventType {
StateEventType::RoomCreate
RoomCreateWithCreatorEventContent::TYPE.into()
}
}

Expand All @@ -156,3 +157,11 @@ impl RedactContent for RoomCreateWithCreatorEventContent {
fn default_create_room_version_id() -> RoomVersionId {
RoomVersionId::V1
}

impl PossiblyRedactedStateEventContent for RoomCreateWithCreatorEventContent {
type StateKey = <RoomCreateWithCreatorEventContent as StateEventContent>::StateKey;

fn event_type(&self) -> StateEventType {
RoomCreateWithCreatorEventContent::TYPE.into()
}
}
30 changes: 14 additions & 16 deletions crates/matrix-sdk-base/src/room/display_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -544,9 +544,11 @@ mod tests {
events::{
StateEventType,
room::{
canonical_alias::RoomCanonicalAliasEventContent,
canonical_alias::{
PossiblyRedactedRoomCanonicalAliasEventContent, RoomCanonicalAliasEventContent,
},
member::{MembershipState, RoomMemberEventContent, StrippedRoomMemberEvent},
name::RoomNameEventContent,
name::{PossiblyRedactedRoomNameEventContent, RoomNameEventContent},
},
},
room_alias_id, room_id,
Expand All @@ -557,8 +559,7 @@ mod tests {

use super::{Room, RoomDisplayName, compute_display_name_from_heroes};
use crate::{
MinimalStateEvent, OriginalMinimalStateEvent, RoomHero, RoomState, StateChanges,
StateStore, store::MemoryStore,
MinimalStateEvent, RoomHero, RoomState, StateChanges, StateStore, store::MemoryStore,
};

fn make_room_test_helper(room_type: RoomState) -> (Arc<MemoryStore>, Room) {
Expand All @@ -584,22 +585,22 @@ mod tests {
}

fn make_canonical_alias_event() -> MinimalStateEvent<RoomCanonicalAliasEventContent> {
MinimalStateEvent::Original(OriginalMinimalStateEvent {
content: assign!(RoomCanonicalAliasEventContent::new(), {
MinimalStateEvent {
content: assign!(PossiblyRedactedRoomCanonicalAliasEventContent::new(), {
alias: Some(room_alias_id!("#test:example.com").to_owned()),
}),
event_id: None,
})
}
}

fn make_name_event_with(name: &str) -> MinimalStateEvent<RoomNameEventContent> {
MinimalStateEvent::Original(OriginalMinimalStateEvent {
content: RoomNameEventContent::new(name.to_owned()),
fn make_name_event_with(name: &str) -> MinimalStateEvent<PossiblyRedactedRoomNameEventContent> {
MinimalStateEvent {
content: RoomNameEventContent::new(name.to_owned()).into(),
event_id: None,
})
}
}

fn make_name_event() -> MinimalStateEvent<RoomNameEventContent> {
fn make_name_event() -> MinimalStateEvent<PossiblyRedactedRoomNameEventContent> {
make_name_event_with("Test Room")
}

Expand Down Expand Up @@ -697,10 +698,7 @@ mod tests {
async fn test_display_name_for_invited_room_is_empty_if_room_name_empty() {
let (_, room) = make_room_test_helper(RoomState::Invited);

let room_name = MinimalStateEvent::Original(OriginalMinimalStateEvent {
content: RoomNameEventContent::new(String::new()),
event_id: None,
});
let room_name = make_name_event_with("");
room.info.update(|info| info.base_info.name = Some(room_name));

assert_eq!(room.compute_display_name().await.unwrap().into_inner(), RoomDisplayName::Empty);
Expand Down
4 changes: 2 additions & 2 deletions crates/matrix-sdk-base/src/room/members.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ impl RoomMember {
/// Get the display name of the member if there is one.
pub fn display_name(&self) -> Option<&str> {
if let Some(p) = self.profile.as_ref() {
p.as_original().and_then(|e| e.content.displayname.as_deref())
p.content.displayname.as_deref()
} else {
self.event.displayname_value()
}
Expand All @@ -276,7 +276,7 @@ impl RoomMember {
/// Get the avatar url of the member, if there is one.
pub fn avatar_url(&self) -> Option<&MxcUri> {
if let Some(p) = self.profile.as_ref() {
p.as_original().and_then(|e| e.content.avatar_url.as_deref())
p.content.avatar_url.as_deref()
} else {
self.event.avatar_url()
}
Expand Down
7 changes: 2 additions & 5 deletions crates/matrix-sdk-base/src/room/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ pub use tombstone::{PredecessorRoom, SuccessorRoom};
use tracing::{info, instrument, warn};

use crate::{
Error, MinimalStateEvent,
Error,
deserialized_responses::MemberEvent,
notification_settings::RoomNotificationMode,
read_receipts::RoomReadReceipts,
Expand Down Expand Up @@ -244,10 +244,7 @@ impl Room {
/// redacted, all fields except `creator` will be set to their default
/// value.
pub fn create_content(&self) -> Option<RoomCreateWithCreatorEventContent> {
match self.info.read().base_info.create.as_ref()? {
MinimalStateEvent::Original(ev) => Some(ev.content.clone()),
MinimalStateEvent::Redacted(ev) => Some(ev.content.clone()),
}
Some(self.info.read().base_info.create.as_ref()?.content.clone())
}

/// Is this room considered a direct message.
Expand Down
Loading
Loading