feat: server-authoritative case window via users.toml

The /api/oneliners time window is now read per-user from users.toml
(window_hours, default 72h). Clients no longer carry a window:
client.toml oneliner_window_hours, SyncConfig.window_hours, the
?hours=N query param, and the render_case_list cutoff filter are
gone. ETag suffix keeps the effective hours so an admin edit to
users.toml invalidates client caches on the next request.
OnelinersResponse.window_hours stays in the wire format, but now
exists solely to anchor client reconciliation.
This commit is contained in:
2026-04-21 16:48:01 +02:00
parent c8186c9f88
commit 3218fc62bd
24 changed files with 167 additions and 132 deletions
-19
View File
@@ -15,9 +15,6 @@ use thiserror::Error;
/// Fallback polling cadence for `/api/oneliners` in seconds. Chosen to
/// feel real-time without hammering the server.
pub const DEFAULT_POLL_INTERVAL_SECONDS: u64 = 5;
/// Fallback window passed as `?hours=N` to `/api/oneliners`. 72 h so
/// Monday-morning shows Friday's unfinished work.
pub const DEFAULT_ONELINER_WINDOW_HOURS: u32 = 72;
/// Client configuration loaded from a TOML file at a platform-specific
/// path. All fields except the two durations are mandatory.
@@ -31,10 +28,6 @@ pub struct Config {
/// built-in default.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub oneliner_poll_interval_seconds: Option<u64>,
/// Time window handed to the server as `?hours=N`. Omit in TOML to
/// use the built-in default.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub oneliner_window_hours: Option<u32>,
}
#[derive(Debug, Error)]
@@ -103,12 +96,6 @@ impl Config {
.unwrap_or(DEFAULT_POLL_INTERVAL_SECONDS),
)
}
/// Window-hours parameter for `/api/oneliners`, with default.
pub fn window_hours(&self) -> u32 {
self.oneliner_window_hours
.unwrap_or(DEFAULT_ONELINER_WINDOW_HOURS)
}
}
#[cfg(test)]
@@ -121,7 +108,6 @@ mod tests {
server_url: "https://doctate.example.org".into(),
api_key: "sk-test-12345".into(),
oneliner_poll_interval_seconds: None,
oneliner_window_hours: None,
}
}
@@ -166,7 +152,6 @@ mod tests {
std::fs::write(&path, "server_url = \"http://x\"\napi_key = \"y\"\n").unwrap();
let cfg = Config::load_from(&path).unwrap().unwrap();
assert_eq!(cfg.poll_interval(), Duration::from_secs(5));
assert_eq!(cfg.window_hours(), 72);
}
#[test]
@@ -175,10 +160,8 @@ mod tests {
server_url: "http://x".into(),
api_key: "y".into(),
oneliner_poll_interval_seconds: Some(10),
oneliner_window_hours: Some(24),
};
assert_eq!(cfg.poll_interval(), Duration::from_secs(10));
assert_eq!(cfg.window_hours(), 24);
}
#[test]
@@ -189,11 +172,9 @@ mod tests {
server_url: "http://x".into(),
api_key: "y".into(),
oneliner_poll_interval_seconds: Some(3),
oneliner_window_hours: Some(168),
};
original.save_to(&path).unwrap();
let loaded = Config::load_from(&path).unwrap().unwrap();
assert_eq!(loaded.oneliner_poll_interval_seconds, Some(3));
assert_eq!(loaded.oneliner_window_hours, Some(168));
}
}