add redis rate limiter

This commit is contained in:
miloschwartz
2025-06-19 16:57:54 -04:00
parent 377eb2b851
commit 494b54ac32
6 changed files with 56 additions and 22 deletions

View File

@@ -21,13 +21,13 @@ export const startOfflineChecker = (): void => {
offlineCheckerInterval = setInterval(async () => {
try {
const twoMinutesAgo = new Date(Date.now() - OFFLINE_THRESHOLD_MS);
// Find clients that haven't pinged in the last 2 minutes and mark them as offline
await db
.update(clients)
.set({ online: false })
.where(
eq(clients.online, true) &&
eq(clients.online, true) &&
(lt(clients.lastPing, twoMinutesAgo.toISOString()) || isNull(clients.lastPing))
);
@@ -90,4 +90,4 @@ export const handleOlmPingMessage: MessageHandler = async (context) => {
broadcast: false,
excludeSender: false
};
};
};

View File

@@ -398,7 +398,7 @@ if (redisManager.isRedisEnabled()) {
});
logger.info(`WebSocket handler initialized with Redis support - Node ID: ${NODE_ID}`);
} else {
logger.info('WebSocket handler initialized in local mode (Redis disabled)');
logger.debug('WebSocket handler initialized in local mode (Redis disabled)');
}
// Cleanup function for graceful shutdown