mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-18 16:21:24 +01:00
implement per-event state filtering for joined rooms in /sync
This commit is contained in:
parent
f4f3be8c30
commit
98d93da3a8
1 changed files with 23 additions and 8 deletions
|
|
@ -605,7 +605,10 @@ async fn load_joined_room(
|
|||
error!("Pdu in state not found: {}", id);
|
||||
continue;
|
||||
};
|
||||
state_events.push(pdu);
|
||||
|
||||
if filter.room.state.pdu_event_allowed(&pdu) {
|
||||
state_events.push(pdu);
|
||||
}
|
||||
|
||||
i += 1;
|
||||
if i % 100 == 0 {
|
||||
|
|
@ -624,12 +627,15 @@ async fn load_joined_room(
|
|||
continue;
|
||||
};
|
||||
|
||||
// This check is in case a bad user ID made it into the
|
||||
// database
|
||||
if let Ok(uid) = UserId::parse(&state_key) {
|
||||
lazy_loaded.insert(uid);
|
||||
if filter.room.state.pdu_event_allowed(&pdu) {
|
||||
// This check is in case a bad user ID made it into
|
||||
// the database
|
||||
if let Ok(uid) = UserId::parse(&state_key) {
|
||||
lazy_loaded.insert(uid);
|
||||
}
|
||||
|
||||
state_events.push(pdu);
|
||||
}
|
||||
state_events.push(pdu);
|
||||
|
||||
i += 1;
|
||||
if i % 100 == 0 {
|
||||
|
|
@ -809,6 +815,9 @@ async fn load_joined_room(
|
|||
let mut state_events = delta_state_events;
|
||||
let mut lazy_loaded = HashSet::new();
|
||||
|
||||
state_events
|
||||
.retain(|pdu| filter.room.state.pdu_event_allowed(pdu));
|
||||
|
||||
// Mark all member events we're returning as lazy-loaded
|
||||
for pdu in &state_events {
|
||||
if pdu.kind == TimelineEventType::RoomMember {
|
||||
|
|
@ -857,8 +866,14 @@ async fn load_joined_room(
|
|||
event.sender.as_str(),
|
||||
)?
|
||||
{
|
||||
lazy_loaded.insert(event.sender.clone());
|
||||
state_events.push(member_event);
|
||||
if filter
|
||||
.room
|
||||
.state
|
||||
.pdu_event_allowed(&member_event)
|
||||
{
|
||||
lazy_loaded.insert(event.sender.clone());
|
||||
state_events.push(member_event);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue