diff --git a/src/api/client_server/sync.rs b/src/api/client_server/sync.rs index 214f2f8e..9d9ccc91 100644 --- a/src/api/client_server/sync.rs +++ b/src/api/client_server/sync.rs @@ -951,6 +951,26 @@ async fn load_joined_room( vec![] }; + let account_data_events = if filter.room.account_data.room_allowed(room_id) + { + services() + .account_data + .changes_since(Some(room_id), sender_user, since)? + .into_iter() + .filter_map(|(_, v)| { + serde_json::from_str(v.json().get()) + .map_err(|_| { + Error::bad_database( + "Invalid account event in database.", + ) + }) + .ok() + }) + .collect() + } else { + vec![] + }; + // Save the state after this sync so we can send the correct state diff next // sync services().rooms.user.associate_token_shortstatehash( @@ -961,20 +981,7 @@ async fn load_joined_room( Ok(JoinedRoom { account_data: RoomAccountData { - events: services() - .account_data - .changes_since(Some(room_id), sender_user, since)? - .into_iter() - .filter_map(|(_, v)| { - serde_json::from_str(v.json().get()) - .map_err(|_| { - Error::bad_database( - "Invalid account event in database.", - ) - }) - .ok() - }) - .collect(), + events: account_data_events, }, summary: RoomSummary { heroes, diff --git a/src/utils/filter.rs b/src/utils/filter.rs index d846af23..18ff18b4 100644 --- a/src/utils/filter.rs +++ b/src/utils/filter.rs @@ -158,6 +158,7 @@ pub(crate) struct CompiledFilterDefinition<'a> { pub(crate) struct CompiledRoomFilter<'a> { rooms: AllowDenyList<'a, RoomId>, + pub(crate) account_data: CompiledRoomEventFilter<'a>, pub(crate) timeline: CompiledRoomEventFilter<'a>, pub(crate) ephemeral: CompiledRoomEventFilter<'a>, pub(crate) state: CompiledRoomEventFilter<'a>, @@ -198,6 +199,7 @@ impl<'a> TryFrom<&'a RoomFilter> for CompiledRoomFilter<'a> { source.rooms.as_deref(), &source.not_rooms, ), + account_data: (&source.account_data).try_into()?, timeline: (&source.timeline).try_into()?, ephemeral: (&source.ephemeral).try_into()?, state: (&source.state).try_into()?,