From aafdeb9ffaf9a993ca4462b3422667e04469b2e3 Mon Sep 17 00:00:00 2001 From: Owen Jacobson Date: Fri, 20 Sep 2024 16:09:35 -0400 Subject: Expire messages after 90 days. This is intended to manage storage growth. A community with broadly steady traffic will now reach a steady state (ish) where the amount of storage in use stays within a steady band. The 90 day threshold is a spitball; this should be made configurable for the community's needs. I've also hoisted expiry out into the `app` classes, to reduce the amount of non-database work repo types are doing. This should make it easier to make expiry configurable later on. Includes incidental cleanup and style changes. --- src/events.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/events.rs') diff --git a/src/events.rs b/src/events.rs index fd73d63..2f5e145 100644 --- a/src/events.rs +++ b/src/events.rs @@ -15,6 +15,7 @@ use futures::stream::{self, Stream, StreamExt as _, TryStreamExt as _}; use crate::{ app::App, channel::{app::EventsError, repo::broadcast}, + clock::RequestedAt, error::InternalError, header::LastEventId, repo::{channel, login::Login}, @@ -32,6 +33,7 @@ struct EventsQuery { async fn on_events( State(app): State, + RequestedAt(now): RequestedAt, _: Login, // requires auth, but doesn't actually care who you are last_event_id: Option, Query(query): Query, @@ -50,7 +52,7 @@ async fn on_events( async move { let events = app .channels() - .events(&channel, resume_at.as_ref()) + .events(&channel, &now, resume_at.as_ref()) .await? .map(ChannelEvent::wrap(channel)); -- cgit v1.2.3