feat: Delayed events support

Includes stable support.

Co-authored-by: new-years-eve <new-years-evening@proton.me>
This commit is contained in:
Henry-Hilesandnew-years-eve committed 2026-12-04 00:55:08 -05:00
1 parent 2f356eaa91
commit 6a1f29cd03
21 files changed
+875 -67

No files matched your search

+19
View File
@@ -920,6 +920,21 @@ pub struct Config {
#[serde(default)]
pub forget_forced_upon_leave: bool,
/// The maximum delay in milliseconds for delayed events (MSC4140). Setting
/// this or `delayed_events_max_scheduled` to 0 disables delayed events.
///
/// default: 604800000
#[serde(default = "default_delayed_events_max_delay_ms")]
pub delayed_events_max_delay_ms: u64,
/// The maximum number of delayed events each user can have scheduled at
/// once. Setting this or `delayed_events_max_delay_ms` to 0 disables
/// delayed events.
///
/// default: 100
#[serde(default = "default_delayed_events_max_scheduled")]
pub delayed_events_max_scheduled: u64,
/// Set this to true to require authentication when looking up user profiles
/// through this server.
///
@@ -3444,6 +3459,10 @@ fn default_unauthenticated_request_ratelimit<K: Hash + Eq + Clone>() -> PerMinut
PerMinuteRatelimiter::new(Quota::per_minute(30.try_into().unwrap()))
}
fn default_delayed_events_max_delay_ms() -> u64 { 7 * 24 * 60 * 60 * 1000 }
fn default_delayed_events_max_scheduled() -> u64 { 100 }
fn default_additional_scopes() -> Vec<Scope> { vec![Scope::new("profile".to_owned())] }
// NOTE: This must be declared *after* every config struct in this file. The
+2
View File
@@ -69,9 +69,11 @@ impl Pdu {
if context.user_id.is_none_or(|u| u != self.sender()) {
unsigned.remove("transaction_id");
unsigned.remove("delay_id");
}
} else {
unsigned.remove("transaction_id");
unsigned.remove("delay_id");
}
if let Some(expires_at) = self
+4
View File
@@ -53,5 +53,9 @@ pub fn unstable_features(experiments: &Experiments) -> BTreeMap<String, bool> {
// Sticky events (https://github.com/matrix-org/matrix-spec-proposals/pull/4354)
// Proposal merged, expected for spec v1.20/v2.0
("org.matrix.msc4354".to_owned(), true),
// Delayed events (https://github.com/matrix-org/matrix-spec-proposals/pull/4140)
// Proposal merged, expected for spec v1.20/v2.0
("org.matrix.msc4140".to_owned(), true),
("org.matrix.msc4140.stable".to_owned(), true),
])
}