From 05d68724f31b738c32b3a18ffd507accc5bea975 Mon Sep 17 00:00:00 2001 From: Ultradesu Date: Wed, 29 Jul 2026 14:21:32 +0100 Subject: [PATCH] Fixed invite logic to be lightweight --- Cargo.toml | 2 +- src/federation/devices.rs | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 1016552..2574686 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "furumusic" -version = "0.9.7" +version = "0.9.8" edition = "2024" description = "Reusable web-app boilerplate: auth, OIDC/SSO, admin panel, user management, i18n, PostgreSQL" diff --git a/src/federation/devices.rs b/src/federation/devices.rs index 790dbbd..0223c1b 100644 --- a/src/federation/devices.rs +++ b/src/federation/devices.rs @@ -32,6 +32,9 @@ const RESPONSE_DRAIN_TIMEOUT: Duration = Duration::from_secs(2); const DEVICE_SYNC_INTERVAL: Duration = Duration::from_secs(2); const LOCAL_SEED_RECHECK_MS: i64 = 60 * 1000; const MAX_LINE: usize = 8 * 1024 * 1024; +/// Playback commands carry queue state but are useful only briefly and only +/// to their addressed device. They must not inflate a new peer's catch-up. +const PLAYBACK_COMMAND_TTL_MS: i64 = 5 * 60 * 1_000; const MAX_OPS_PER_BATCH: i64 = 1000; #[derive(Debug, Clone, Serialize)] @@ -4226,11 +4229,19 @@ async fn ops_for_peer( AND a.origin_device_id = o.origin_device_id WHERE o.user_id = $1 AND o.seq > COALESCE(a.max_seq, 0) + AND ( + o.kind != 'playback_command' + OR ( + o.hlc_ms >= $3 + AND o.payload_json->>'target_device_id' = $2 + ) + ) ORDER BY o.hlc_ms, o.op_id - LIMIT $3", + LIMIT $4", ) .bind(user_id) .bind(peer_device_id) + .bind(now_ms().saturating_sub(PLAYBACK_COMMAND_TTL_MS)) .bind(MAX_OPS_PER_BATCH) .fetch_all(pool) .await?;