fix notifications + improve them, improve normal UI stuff further + fix readme.
This commit is contained in:
@@ -1839,11 +1839,6 @@ export function getNotificationScreenshot(notificationId: string): NotificationS
|
||||
};
|
||||
}
|
||||
|
||||
export function clearNotificationScreenshots() {
|
||||
db.run(`DELETE FROM notification_screenshots`);
|
||||
console.log("[db] cleared notification screenshots");
|
||||
}
|
||||
|
||||
export type NotificationRow = {
|
||||
id: string;
|
||||
clientId: string;
|
||||
@@ -1910,14 +1905,17 @@ export function getNotificationHistory(limit: number = 500): NotificationRow[] {
|
||||
}));
|
||||
}
|
||||
|
||||
const NOTIFICATION_RETENTION_MS = 3 * 24 * 60 * 60 * 1000;
|
||||
const NOTIFICATION_RETENTION_DAYS = 3;
|
||||
const NOTIFICATION_RETENTION_MS = NOTIFICATION_RETENTION_DAYS * 24 * 60 * 60 * 1000;
|
||||
|
||||
export function pruneOldNotifications() {
|
||||
const cutoff = Date.now() - NOTIFICATION_RETENTION_MS;
|
||||
db.run(`DELETE FROM notification_screenshots WHERE notification_id IN (SELECT id FROM notifications WHERE ts < ?)`, cutoff);
|
||||
db.run(`DELETE FROM notification_screenshots WHERE ts < ?`, cutoff);
|
||||
db.run(`DELETE FROM notification_screenshots WHERE notification_id NOT IN (SELECT id FROM notifications)`);
|
||||
const result = db.run(`DELETE FROM notifications WHERE ts < ?`, cutoff);
|
||||
if (result.changes > 0) {
|
||||
console.log(`[db] pruned ${result.changes} notifications older than 3 days`);
|
||||
console.log(`[db] pruned ${result.changes} notifications older than ${NOTIFICATION_RETENTION_DAYS} days`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import { fileURLToPath } from "url";
|
||||
import path from "path";
|
||||
import fs from "fs/promises";
|
||||
import { existsSync } from "node:fs";
|
||||
import { upsertClientRow, setOnlineState, listClients, markAllClientsOffline, getBuild, getBuildByTag, getAllBuilds, deleteExpiredBuilds, deleteBuild, getNotificationScreenshot, clearNotificationScreenshots, deleteClientRow, getClientIp, banIp, isIpBanned, clientExists, deleteExpiredSharedFiles, getChatHistory, insertChatMessage, getOnlineClientCountForUser, deleteExpiredChatMessages, recordBuildClaim, getClientMetricsSummary, pruneOldNotifications } from "./db";
|
||||
import { upsertClientRow, setOnlineState, listClients, markAllClientsOffline, getBuild, getBuildByTag, getAllBuilds, deleteExpiredBuilds, deleteBuild, getNotificationScreenshot, deleteClientRow, getClientIp, banIp, isIpBanned, clientExists, deleteExpiredSharedFiles, getChatHistory, insertChatMessage, getOnlineClientCountForUser, deleteExpiredChatMessages, recordBuildClaim, getClientMetricsSummary, pruneOldNotifications } from "./db";
|
||||
import { handleFrame, handleHello, handlePing, handlePong } from "./wsHandlers";
|
||||
import { getMessageByteLength, getMaxPayloadLimit, isAllowedClientMessageType } from "./wsValidation";
|
||||
import { ClientInfo, ClientRole } from "./types";
|
||||
@@ -732,7 +732,6 @@ async function startServer() {
|
||||
|
||||
|
||||
markAllClientsOffline();
|
||||
clearNotificationScreenshots();
|
||||
loadOrGenerateVapidKeys();
|
||||
|
||||
deleteExpiredBuilds();
|
||||
|
||||
Reference in New Issue
Block a user