summaryrefslogtreecommitdiff
path: root/src/events.rs
diff options
context:
space:
mode:
authorOwen Jacobson <owen@grimoire.ca>2024-09-20 16:09:35 -0400
committerOwen Jacobson <owen@grimoire.ca>2024-09-20 16:42:25 -0400
commitaafdeb9ffaf9a993ca4462b3422667e04469b2e3 (patch)
treeef2c0b8a8719a3ad511c80b38b3669d9f0c49157 /src/events.rs
parent8fe54f09aad3121d1cb9418087e46dc3a617463a (diff)
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.
Diffstat (limited to 'src/events.rs')
-rw-r--r--src/events.rs4
1 files changed, 3 insertions, 1 deletions
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<App>,
+ RequestedAt(now): RequestedAt,
_: Login, // requires auth, but doesn't actually care who you are
last_event_id: Option<LastEventId>,
Query(query): Query<EventsQuery>,
@@ -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));