mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-05-26 20:49:55 +00:00
perf: Move rejected events check
This commit is contained in:
@@ -37,8 +37,6 @@ where
|
|||||||
// 1. Remove unsigned field
|
// 1. Remove unsigned field
|
||||||
value.remove("unsigned");
|
value.remove("unsigned");
|
||||||
|
|
||||||
// TODO: For RoomVersion6 we must check that Raw<..> is canonical do we anywhere?: https://matrix.org/docs/spec/rooms/v6#canonical-json
|
|
||||||
|
|
||||||
// 2. Check signatures, otherwise drop
|
// 2. Check signatures, otherwise drop
|
||||||
// 3. check content hash, redact if doesn't match
|
// 3. check content hash, redact if doesn't match
|
||||||
let room_version_rules = get_room_version_rules(create_event)?;
|
let room_version_rules = get_room_version_rules(create_event)?;
|
||||||
@@ -90,6 +88,15 @@ where
|
|||||||
let mut auth_events: HashMap<OwnedEventId, PduEvent> = HashMap::new();
|
let mut auth_events: HashMap<OwnedEventId, PduEvent> = HashMap::new();
|
||||||
|
|
||||||
for aid in pdu_event.auth_events() {
|
for aid in pdu_event.auth_events() {
|
||||||
|
if self.services.pdu_metadata.is_event_rejected(aid).await {
|
||||||
|
debug_warn!(
|
||||||
|
"Rejecting incoming event {} which depends on rejected auth event {aid}",
|
||||||
|
event_id,
|
||||||
|
);
|
||||||
|
self.services.pdu_metadata.mark_event_rejected(event_id);
|
||||||
|
return Err!(Request(InvalidParam("Event has rejected auth event: {aid}")));
|
||||||
|
}
|
||||||
|
|
||||||
if let Ok(auth_event) = self.services.timeline.get_pdu(aid).await {
|
if let Ok(auth_event) = self.services.timeline.get_pdu(aid).await {
|
||||||
check_room_id(room_id, &auth_event)?;
|
check_room_id(room_id, &auth_event)?;
|
||||||
trace!("Found auth event {aid} for outlier event {event_id} locally");
|
trace!("Found auth event {aid} for outlier event {event_id} locally");
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
use std::{borrow::Borrow, collections::BTreeMap, sync::Arc, time::Instant};
|
use std::{borrow::Borrow, collections::BTreeMap, sync::Arc, time::Instant};
|
||||||
|
|
||||||
use conduwuit::{
|
use conduwuit::{
|
||||||
debug, debug_info, debug_warn, err, implement, is_equal_to, matrix::{state_res, Event, EventTypeExt, PduEvent, StateKey}, trace,
|
Err, Result, debug, debug_info, debug_warn, err, implement, is_equal_to,
|
||||||
|
matrix::{Event, EventTypeExt, PduEvent, StateKey, state_res},
|
||||||
|
trace,
|
||||||
utils::{
|
utils::{
|
||||||
stream::{BroadbandExt, ReadyExt},
|
|
||||||
IterStream,
|
IterStream,
|
||||||
|
stream::{BroadbandExt, ReadyExt},
|
||||||
},
|
},
|
||||||
warn,
|
warn,
|
||||||
Err,
|
|
||||||
Result,
|
|
||||||
};
|
};
|
||||||
use futures::{future::ready, FutureExt, StreamExt};
|
use futures::{FutureExt, StreamExt, future::ready};
|
||||||
use ruma::{events::StateEventType, CanonicalJsonValue, RoomId, ServerName};
|
use ruma::{CanonicalJsonValue, RoomId, ServerName, events::StateEventType};
|
||||||
use tokio::join;
|
use tokio::join;
|
||||||
|
|
||||||
use super::get_room_version_rules;
|
use super::get_room_version_rules;
|
||||||
@@ -56,20 +56,6 @@ where
|
|||||||
return Err!(Request(InvalidParam("Event has been soft-failed")));
|
return Err!(Request(InvalidParam("Event has been soft-failed")));
|
||||||
}
|
}
|
||||||
|
|
||||||
// If any of the auth events are rejected, this event is also rejected.
|
|
||||||
for aid in incoming_pdu.auth_events() {
|
|
||||||
if self.services.pdu_metadata.is_event_rejected(aid).await {
|
|
||||||
debug_warn!(
|
|
||||||
"Rejecting incoming event {} which depends on rejected auth event {aid}",
|
|
||||||
incoming_pdu.event_id()
|
|
||||||
);
|
|
||||||
self.services
|
|
||||||
.pdu_metadata
|
|
||||||
.mark_event_rejected(incoming_pdu.event_id());
|
|
||||||
return Err!(Request(InvalidParam("Event has rejected auth event: {aid}")));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
debug!(
|
debug!(
|
||||||
event_id = %incoming_pdu.event_id,
|
event_id = %incoming_pdu.event_id,
|
||||||
"Upgrading PDU from outlier to timeline"
|
"Upgrading PDU from outlier to timeline"
|
||||||
|
|||||||
Reference in New Issue
Block a user