mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-05-26 20:49:55 +00:00
fix: Store PDUs as outliers even when rejected
This prevents future network lookups if we've already rejected an event and see a reference to it again
This commit is contained in:
@@ -1,13 +1,13 @@
|
|||||||
use std::collections::{BTreeMap, HashMap, hash_map};
|
use std::collections::{hash_map, BTreeMap, HashMap};
|
||||||
|
|
||||||
use conduwuit::{
|
use conduwuit::{
|
||||||
Err, Event, PduEvent, Result, debug, debug_info, debug_warn, err, implement, state_res,
|
debug, debug_info, debug_warn, err, implement, state_res, trace, warn, Err, Event,
|
||||||
trace, warn,
|
PduEvent, Result,
|
||||||
};
|
};
|
||||||
use futures::future::ready;
|
use futures::future::ready;
|
||||||
use ruma::{
|
use ruma::{
|
||||||
CanonicalJsonObject, CanonicalJsonValue, EventId, OwnedEventId, RoomId, ServerName,
|
events::StateEventType, CanonicalJsonObject, CanonicalJsonValue, EventId, OwnedEventId, RoomId,
|
||||||
events::StateEventType,
|
ServerName,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{check_room_id, get_room_version_rules};
|
use super::{check_room_id, get_room_version_rules};
|
||||||
@@ -165,6 +165,9 @@ where
|
|||||||
v.insert(auth_event);
|
v.insert(auth_event);
|
||||||
},
|
},
|
||||||
| hash_map::Entry::Occupied(_) => {
|
| hash_map::Entry::Occupied(_) => {
|
||||||
|
self.services
|
||||||
|
.outlier
|
||||||
|
.add_pdu_outlier(pdu_event.event_id(), &incoming_pdu);
|
||||||
self.services.pdu_metadata.mark_event_rejected(event_id);
|
self.services.pdu_metadata.mark_event_rejected(event_id);
|
||||||
return Err!(Request(InvalidParam(
|
return Err!(Request(InvalidParam(
|
||||||
"Auth event's type and state_key combination exists multiple times: {}, {}",
|
"Auth event's type and state_key combination exists multiple times: {}, {}",
|
||||||
@@ -181,6 +184,9 @@ where
|
|||||||
Some(_) | None
|
Some(_) | None
|
||||||
) {
|
) {
|
||||||
self.services.pdu_metadata.mark_event_rejected(event_id);
|
self.services.pdu_metadata.mark_event_rejected(event_id);
|
||||||
|
self.services
|
||||||
|
.outlier
|
||||||
|
.add_pdu_outlier(pdu_event.event_id(), &incoming_pdu);
|
||||||
return Err!(Request(InvalidParam("Incoming event refers to wrong create event.")));
|
return Err!(Request(InvalidParam("Incoming event refers to wrong create event.")));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,6 +208,9 @@ where
|
|||||||
|
|
||||||
if !auth_check {
|
if !auth_check {
|
||||||
self.services.pdu_metadata.mark_event_rejected(event_id);
|
self.services.pdu_metadata.mark_event_rejected(event_id);
|
||||||
|
self.services
|
||||||
|
.outlier
|
||||||
|
.add_pdu_outlier(pdu_event.event_id(), &incoming_pdu);
|
||||||
return Err!(Request(Forbidden(
|
return Err!(Request(Forbidden(
|
||||||
"Event authorisation fails based on event's claimed auth events"
|
"Event authorisation fails based on event's claimed auth events"
|
||||||
)));
|
)));
|
||||||
|
|||||||
Reference in New Issue
Block a user