From 5199cde870b4aaf43c1e5b1f3547128d8fc491a5 Mon Sep 17 00:00:00 2001 From: Jade Ellis Date: Sun, 28 Jun 2026 03:44:23 +0100 Subject: [PATCH] feat: Allow sending dummy events to clients --- conduwuit-example.toml | 5 +++++ src/api/client/message.rs | 4 +++- src/core/config/mod.rs | 5 +++++ .../rooms/event_handler/handle_outlier_pdu.rs | 20 +++++++++++++------ .../event_handler/upgrade_outlier_pdu.rs | 14 +++++++------ src/service/rooms/timeline/backfill.rs | 2 +- 6 files changed, 36 insertions(+), 14 deletions(-) diff --git a/conduwuit-example.toml b/conduwuit-example.toml index 1742db047..893400ec1 100644 --- a/conduwuit-example.toml +++ b/conduwuit-example.toml @@ -1436,6 +1436,11 @@ # #send_messages_from_ignored_users_to_client = false +# Send "org.matrix.dummy_event" events to the client. This is a debugging +# option. +# +#send_dummy_events_to_clients = false + # Vector list of IPv4 and IPv6 CIDR ranges / subnets *in quotes* that you # do not want continuwuity to send outbound requests to. Defaults to # RFC1918, unroutable, loopback, multicast, and testnet addresses for diff --git a/src/api/client/message.rs b/src/api/client/message.rs index a2da36e48..2c3ccc782 100644 --- a/src/api/client/message.rs +++ b/src/api/client/message.rs @@ -291,7 +291,9 @@ where { // exclude Synapse's dummy events from bloating up response bodies. clients // don't need to see this. - if event.kind().to_string() == "org.matrix.dummy_event" { + if !services.config.send_dummy_events_to_clients + && event.kind().to_string() == "org.matrix.dummy_event" + { return Ok(true); } diff --git a/src/core/config/mod.rs b/src/core/config/mod.rs index f8a0846d0..661098485 100644 --- a/src/core/config/mod.rs +++ b/src/core/config/mod.rs @@ -1661,6 +1661,11 @@ pub struct Config { #[serde(default)] pub send_messages_from_ignored_users_to_client: bool, + /// Send "org.matrix.dummy_event" events to the client. This is a debugging + /// option. + #[serde(default)] + pub send_dummy_events_to_clients: bool, + /// Vector list of IPv4 and IPv6 CIDR ranges / subnets *in quotes* that you /// do not want continuwuity to send outbound requests to. Defaults to /// RFC1918, unroutable, loopback, multicast, and testnet addresses for diff --git a/src/service/rooms/event_handler/handle_outlier_pdu.rs b/src/service/rooms/event_handler/handle_outlier_pdu.rs index 5c7ef0bfa..470cd6643 100644 --- a/src/service/rooms/event_handler/handle_outlier_pdu.rs +++ b/src/service/rooms/event_handler/handle_outlier_pdu.rs @@ -1,8 +1,8 @@ use std::collections::{BTreeMap, HashMap, hash_map}; use conduwuit::{ - Err, Event, PduEvent, Result, debug, debug_info, debug_warn, err, info, state_res, - trace, warn, + Err, Event, PduEvent, Result, debug, debug_info, debug_warn, err, info, state_res, trace, + warn, }; use futures::future::ready; use ruma::{ @@ -104,14 +104,21 @@ impl super::Service { let mut auth_events: HashMap = HashMap::new(); for auth_event_id in pdu_event.auth_events() { - if self.services.pdu_metadata.is_event_rejected(auth_event_id).await { + if self + .services + .pdu_metadata + .is_event_rejected(auth_event_id) + .await + { debug_warn!( "Rejecting incoming event {} which depends on rejected auth event \ - {auth_event_id}", + {auth_event_id}", event_id, ); self.services.pdu_metadata.mark_event_rejected(event_id); - return Err!(Request(Forbidden("Event has rejected auth event: {auth_event_id}"))); + return Err!(Request(Forbidden( + "Event has rejected auth event: {auth_event_id}" + ))); } if let Ok(auth_event) = self.services.timeline.get_pdu(auth_event_id).await { @@ -120,7 +127,8 @@ impl super::Service { auth_events.insert(auth_event_id.to_owned(), auth_event); } else { debug_warn!( - "Could not find auth event {auth_event_id} for outlier event {event_id} locally" + "Could not find auth event {auth_event_id} for outlier event {event_id} \ + locally" ); } } diff --git a/src/service/rooms/event_handler/upgrade_outlier_pdu.rs b/src/service/rooms/event_handler/upgrade_outlier_pdu.rs index 845c62455..c6099ccf8 100644 --- a/src/service/rooms/event_handler/upgrade_outlier_pdu.rs +++ b/src/service/rooms/event_handler/upgrade_outlier_pdu.rs @@ -26,16 +26,16 @@ use crate::rooms::{ impl super::Service { #[tracing::instrument(name="upgrade_outlier", skip_all, fields(event_id=%incoming_pdu.event_id()))] pub(super) async fn upgrade_outlier_to_timeline_pdu( - &self, - incoming_pdu: PduEvent, - mut val: CanonicalJsonObject, - create_event: &PduEvent, + &self, + incoming_pdu: PduEvent, + mut val: CanonicalJsonObject, + create_event: &PduEvent, origin: &ServerName, room_id: &RoomId, ) -> Result> { let (pduid, rejected, soft_failed) = join!( self.services.timeline.get_pdu_id(incoming_pdu.event_id()), - self.services + self.services .pdu_metadata .is_event_rejected(incoming_pdu.event_id()), self.services @@ -85,7 +85,9 @@ impl super::Service { trace!("Could not calculate incoming state, asking remote {origin} for it"); self.fetch_state(origin, create_event, room_id, incoming_pdu.event_id()) .await - .debug_inspect_err(|e| debug_error!("Could not fetch state from {origin}: {e}"))? + .debug_inspect_err(|e| { + debug_error!("Could not fetch state from {origin}: {e}"); + })? }, }; diff --git a/src/service/rooms/timeline/backfill.rs b/src/service/rooms/timeline/backfill.rs index 3bbda9d80..36b01c8e8 100644 --- a/src/service/rooms/timeline/backfill.rs +++ b/src/service/rooms/timeline/backfill.rs @@ -228,7 +228,7 @@ impl super::Service { &self, room_id: &RoomId, ) -> HashSet { - let mut candidate_backfill_servers = HashSet::new(); + let mut candidate_backfill_servers = HashSet::new(); let power_levels = self .services