Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
18 changes: 9 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ once_cell = "1.16.0"
pin-project-lite = "0.2.9"
rand = "0.8.5"
reqwest = { version = "0.12.4", default-features = false }
ruma = { git = "https://github.com/matrix-org/ruma", rev = "79289381444e886c454302e1e8f5b5f62f249a57", features = [
ruma = { git = "https://github.com/matrix-org/ruma", rev = "e87f1d839e3821f0fb0ba20fb3164fedbc90a25c", features = [
"client-api-c",
"compat-upload-signatures",
"compat-user-id",
Expand All @@ -61,7 +61,7 @@ ruma = { git = "https://github.com/matrix-org/ruma", rev = "79289381444e886c4543
"unstable-msc4075",
"unstable-msc4140",
] }
ruma-common = { git = "https://github.com/matrix-org/ruma", rev = "79289381444e886c454302e1e8f5b5f62f249a57" }
ruma-common = { git = "https://github.com/matrix-org/ruma", rev = "e87f1d839e3821f0fb0ba20fb3164fedbc90a25c" }
serde = "1.0.151"
serde_html_form = "0.2.0"
serde_json = "1.0.91"
Expand Down
33 changes: 30 additions & 3 deletions crates/matrix-sdk-base/src/rooms/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ use ruma::{
RedactedStateEventContent, StaticStateEventContent, SyncStateEvent,
},
room::RoomType,
EventId, OwnedUserId, RoomVersionId,
EventId, OwnedUserId, RoomVersionId, UserId,
};
use serde::{Deserialize, Serialize};

Expand Down Expand Up @@ -195,9 +195,36 @@ impl BaseRoomInfo {
let mut o_ev = o_ev.clone();
o_ev.content.set_created_ts_if_none(o_ev.origin_server_ts);

let state_key = m.state_key();
let owned_user_id = match UserId::parse(state_key) {
Ok(u) => u,
Err(_) => {
// Ignore leading underscore if present
// (used for avoiding auth rules on @-prefixed state keys)
let state_key = match state_key.strip_prefix('_') {
None => state_key,
Some(stripped_state_key) => stripped_state_key,
};
if state_key.starts_with('@') {
if let Some(colon_idx) = state_key.find(':') {
let state_key_user_id = match state_key[colon_idx + 1..].find('_') {
None => state_key,
Some(suffix_idx) => &state_key[..colon_idx + 1 + suffix_idx],
};
match UserId::parse(state_key_user_id) {
Ok(u) => u,
Err(_) => return false,
}
} else {
return false;
}
} else {
return false;
}
}
};
// add the new event.
self.rtc_member
.insert(m.state_key().clone(), SyncStateEvent::Original(o_ev).into());
self.rtc_member.insert(owned_user_id, SyncStateEvent::Original(o_ev).into());

// Remove all events that don't contain any memberships anymore.
self.rtc_member.retain(|_, ev| {
Expand Down
2 changes: 1 addition & 1 deletion crates/matrix-sdk-base/src/rooms/normal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2624,7 +2624,7 @@ mod tests {
// we can simply use now here since this will be dropped when using a MinimalStateEvent
// in the roomInfo
origin_server_ts: timestamp(0),
state_key: user_id.to_owned(),
state_key: user_id.to_string(),
unsigned: StateUnsigned::new(),
}))
}
Expand Down