feat: add startup cleanup for old read items

Runs cleanupAllReadItems on server startup to clean up accumulated
read items from all channels, keeping only the 30 most recent per
channel per user.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Ricardo
2026-02-07 00:52:29 +01:00
parent 722a884ca3
commit 6caf37a003
3 changed files with 69 additions and 2 deletions

View File

@@ -6,7 +6,7 @@ import { microsubController } from "./lib/controllers/microsub.js";
import { readerController } from "./lib/controllers/reader.js";
import { handleMediaProxy } from "./lib/media/proxy.js";
import { startScheduler, stopScheduler } from "./lib/polling/scheduler.js";
import { createIndexes } from "./lib/storage/items.js";
import { cleanupAllReadItems, createIndexes } from "./lib/storage/items.js";
import { webmentionReceiver } from "./lib/webmention/receiver.js";
import { websubHandler } from "./lib/websub/handler.js";
@@ -157,6 +157,11 @@ export default class MicrosubEndpoint {
createIndexes(indiekit).catch((error) => {
console.warn("[Microsub] Index creation failed:", error.message);
});
// Cleanup old read items on startup
cleanupAllReadItems(indiekit).catch((error) => {
console.warn("[Microsub] Startup cleanup failed:", error.message);
});
} else {
console.warn(
"[Microsub] Database not available at init, scheduler not started",