mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-19 00:31: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);
|
error!("Pdu in state not found: {}", id);
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
state_events.push(pdu);
|
|
||||||
|
if filter.room.state.pdu_event_allowed(&pdu) {
|
||||||
|
state_events.push(pdu);
|
||||||
|
}
|
||||||
|
|
||||||
i += 1;
|
i += 1;
|
||||||
if i % 100 == 0 {
|
if i % 100 == 0 {
|
||||||
|
|
@ -624,12 +627,15 @@ async fn load_joined_room(
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
|
||||||
// This check is in case a bad user ID made it into the
|
if filter.room.state.pdu_event_allowed(&pdu) {
|
||||||
// database
|
// This check is in case a bad user ID made it into
|
||||||
if let Ok(uid) = UserId::parse(&state_key) {
|
// the database
|
||||||
lazy_loaded.insert(uid);
|
if let Ok(uid) = UserId::parse(&state_key) {
|
||||||
|
lazy_loaded.insert(uid);
|
||||||
|
}
|
||||||
|
|
||||||
|
state_events.push(pdu);
|
||||||
}
|
}
|
||||||
state_events.push(pdu);
|
|
||||||
|
|
||||||
i += 1;
|
i += 1;
|
||||||
if i % 100 == 0 {
|
if i % 100 == 0 {
|
||||||
|
|
@ -809,6 +815,9 @@ async fn load_joined_room(
|
||||||
let mut state_events = delta_state_events;
|
let mut state_events = delta_state_events;
|
||||||
let mut lazy_loaded = HashSet::new();
|
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
|
// Mark all member events we're returning as lazy-loaded
|
||||||
for pdu in &state_events {
|
for pdu in &state_events {
|
||||||
if pdu.kind == TimelineEventType::RoomMember {
|
if pdu.kind == TimelineEventType::RoomMember {
|
||||||
|
|
@ -857,8 +866,14 @@ async fn load_joined_room(
|
||||||
event.sender.as_str(),
|
event.sender.as_str(),
|
||||||
)?
|
)?
|
||||||
{
|
{
|
||||||
lazy_loaded.insert(event.sender.clone());
|
if filter
|
||||||
state_events.push(member_event);
|
.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