mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-05-26 20:49:55 +00:00
perf: Don't handle PDUs for rooms we aren't in
This commit is contained in:
@@ -4,8 +4,8 @@ use std::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use conduwuit::{
|
use conduwuit::{
|
||||||
Err, Event, Result, debug::INFO_SPAN_LEVEL, defer, err, implement, utils::stream::IterStream,
|
Err, Event, Result, debug::INFO_SPAN_LEVEL, debug_warn, defer, err, implement,
|
||||||
warn,
|
utils::stream::IterStream, warn,
|
||||||
};
|
};
|
||||||
use futures::{
|
use futures::{
|
||||||
FutureExt, TryFutureExt, TryStreamExt,
|
FutureExt, TryFutureExt, TryStreamExt,
|
||||||
@@ -70,7 +70,7 @@ pub async fn handle_incoming_pdu<'a>(
|
|||||||
return Err!(Request(TooLarge("PDU is too large")));
|
return Err!(Request(TooLarge("PDU is too large")));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 1.1 Check the server is in the room
|
// 1.1 Check we even know about the room
|
||||||
let meta_exists = self.services.metadata.exists(room_id).map(Ok);
|
let meta_exists = self.services.metadata.exists(room_id).map(Ok);
|
||||||
|
|
||||||
// 1.2 Check if the room is disabled
|
// 1.2 Check if the room is disabled
|
||||||
@@ -114,6 +114,19 @@ pub async fn handle_incoming_pdu<'a>(
|
|||||||
return Err!(Request(Forbidden("Federation of this room is disabled by this server.")));
|
return Err!(Request(Forbidden("Federation of this room is disabled by this server.")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !self
|
||||||
|
.services
|
||||||
|
.state_cache
|
||||||
|
.server_in_room(self.services.globals.server_name(), room_id)
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
debug_warn!(
|
||||||
|
%origin,
|
||||||
|
"Dropping inbound PDU for room we aren't participating in"
|
||||||
|
);
|
||||||
|
return Err!(Request(NotFound("This server is not participating in that room.")));
|
||||||
|
}
|
||||||
|
|
||||||
let (incoming_pdu, val) = self
|
let (incoming_pdu, val) = self
|
||||||
.handle_outlier_pdu(origin, create_event, event_id, room_id, value, false)
|
.handle_outlier_pdu(origin, create_event, event_id, room_id, value, false)
|
||||||
.await?;
|
.await?;
|
||||||
|
|||||||
Reference in New Issue
Block a user