Skip to content

Commit

Permalink
fixup! Revert "feat(knocking): use handle_stripped_state_event to c…
Browse files Browse the repository at this point in the history
…heck the membership state event"
  • Loading branch information
jmartinesp committed Oct 16, 2024
1 parent 87c7fb1 commit 01b3bc9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion crates/matrix-sdk-base/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1148,7 +1148,7 @@ impl BaseClient {
);

let mut room_info = room.clone_info();
room_info.mark_as_invited();
room_info.mark_as_knocked();
room_info.mark_state_fully_synced();

self.handle_invited_state(
Expand Down
19 changes: 12 additions & 7 deletions crates/matrix-sdk-base/src/sliding_sync/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use ruma::{
AnySyncStateEvent,
},
serde::Raw,
JsOption, OwnedRoomId, RoomId, UInt,
JsOption, OwnedRoomId, RoomId, UInt, UserId,
};
use tracing::{debug, error, instrument, trace, warn};

Expand Down Expand Up @@ -171,13 +171,20 @@ impl BaseClient {
let mut notifications = Default::default();
let mut rooms_account_data = extensions.account_data.rooms.clone();

let user_id = self
.session_meta()
.expect("Sliding sync shouldn't run without an authenticated user.")
.user_id
.to_owned();

for (room_id, response_room_data) in rooms {
let (room_info, joined_room, left_room, invited_room, knocked_room) = self
.process_sliding_sync_room(
room_id,
response_room_data,
&mut rooms_account_data,
&store,
&user_id,
&account_data_processor,
&mut changes,
&mut room_info_notable_updates,
Expand Down Expand Up @@ -349,6 +356,7 @@ impl BaseClient {
room_data: &http::response::Room,
rooms_account_data: &mut BTreeMap<OwnedRoomId, Vec<Raw<AnyRoomAccountDataEvent>>>,
store: &Store,
user_id: &UserId,
account_data_processor: &AccountDataProcessor,
changes: &mut StateChanges,
room_info_notable_updates: &mut BTreeMap<OwnedRoomId, RoomInfoNotableUpdateReasons>,
Expand Down Expand Up @@ -421,6 +429,7 @@ impl BaseClient {
room_data.as_ref(),
&state_events,
store,
user_id,
room_id,
room_info_notable_updates,
);
Expand Down Expand Up @@ -560,14 +569,10 @@ impl BaseClient {
room_data: &http::response::Room,
state_events: &[AnySyncStateEvent],
store: &Store,
user_id: &UserId,
room_id: &RoomId,
room_info_notable_updates: &mut BTreeMap<OwnedRoomId, RoomInfoNotableUpdateReasons>,
) -> (Room, RoomInfo, Option<InvitedRoom>, Option<KnockedRoom>) {
let user_id = self
.session_meta()
.expect("Sliding sync shouldn't run without an authenticated user.")
.user_id
.to_owned();
if let Some(invite_state) = &room_data.invite_state {
let room = store.get_or_create_room(
room_id,
Expand All @@ -581,7 +586,7 @@ impl BaseClient {
let membership_event_content = invite_state.iter().find_map(|raw| {
raw.deserialize().ok().iter().find_map(|e| {
if let AnyStrippedStateEvent::RoomMember(membership_event) = e {
if membership_event.sender == user_id {
if membership_event.state_key == user_id {
return Some(membership_event.content.clone());
}
}
Expand Down

0 comments on commit 01b3bc9

Please sign in to comment.