mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-19 00:31:24 +01:00
implement room.account_data.(not_)rooms filter on /sync
This commit is contained in:
parent
84f356e67b
commit
745eaa9b48
2 changed files with 23 additions and 14 deletions
|
|
@ -951,6 +951,26 @@ async fn load_joined_room(
|
||||||
vec![]
|
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
|
// Save the state after this sync so we can send the correct state diff next
|
||||||
// sync
|
// sync
|
||||||
services().rooms.user.associate_token_shortstatehash(
|
services().rooms.user.associate_token_shortstatehash(
|
||||||
|
|
@ -961,20 +981,7 @@ async fn load_joined_room(
|
||||||
|
|
||||||
Ok(JoinedRoom {
|
Ok(JoinedRoom {
|
||||||
account_data: RoomAccountData {
|
account_data: RoomAccountData {
|
||||||
events: services()
|
events: account_data_events,
|
||||||
.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(),
|
|
||||||
},
|
},
|
||||||
summary: RoomSummary {
|
summary: RoomSummary {
|
||||||
heroes,
|
heroes,
|
||||||
|
|
|
||||||
|
|
@ -158,6 +158,7 @@ pub(crate) struct CompiledFilterDefinition<'a> {
|
||||||
|
|
||||||
pub(crate) struct CompiledRoomFilter<'a> {
|
pub(crate) struct CompiledRoomFilter<'a> {
|
||||||
rooms: AllowDenyList<'a, RoomId>,
|
rooms: AllowDenyList<'a, RoomId>,
|
||||||
|
pub(crate) account_data: CompiledRoomEventFilter<'a>,
|
||||||
pub(crate) timeline: CompiledRoomEventFilter<'a>,
|
pub(crate) timeline: CompiledRoomEventFilter<'a>,
|
||||||
pub(crate) ephemeral: CompiledRoomEventFilter<'a>,
|
pub(crate) ephemeral: CompiledRoomEventFilter<'a>,
|
||||||
pub(crate) state: CompiledRoomEventFilter<'a>,
|
pub(crate) state: CompiledRoomEventFilter<'a>,
|
||||||
|
|
@ -198,6 +199,7 @@ impl<'a> TryFrom<&'a RoomFilter> for CompiledRoomFilter<'a> {
|
||||||
source.rooms.as_deref(),
|
source.rooms.as_deref(),
|
||||||
&source.not_rooms,
|
&source.not_rooms,
|
||||||
),
|
),
|
||||||
|
account_data: (&source.account_data).try_into()?,
|
||||||
timeline: (&source.timeline).try_into()?,
|
timeline: (&source.timeline).try_into()?,
|
||||||
ephemeral: (&source.ephemeral).try_into()?,
|
ephemeral: (&source.ephemeral).try_into()?,
|
||||||
state: (&source.state).try_into()?,
|
state: (&source.state).try_into()?,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue