feat(server): cache isFederated flag at WS auth, pass to event handler

This commit is contained in:
Jannis Braun
2026-04-02 10:47:52 +02:00
parent 8f2f494ffd
commit 32d9f16a15
+3 -1
View File
@@ -1374,6 +1374,7 @@ export async function registerWebSocket(app: FastifyInstance): Promise<void> {
let authenticated = false; let authenticated = false;
let userId: string | undefined; let userId: string | undefined;
let username: string | undefined; let username: string | undefined;
let isFederated = false;
// Set auth timeout - must authenticate within 10 seconds // Set auth timeout - must authenticate within 10 seconds
const authTimeout = setTimeout(() => { const authTimeout = setTimeout(() => {
@@ -1427,6 +1428,7 @@ export async function registerWebSocket(app: FastifyInstance): Promise<void> {
} }
authenticated = true; authenticated = true;
isFederated = !!userRow.homeInstance;
clearTimeout(authTimeout); clearTimeout(authTimeout);
// Update user status to online // Update user status to online
@@ -1477,7 +1479,7 @@ export async function registerWebSocket(app: FastifyInstance): Promise<void> {
// Handle authenticated events // Handle authenticated events
if (userId && username) { if (userId && username) {
try { try {
handleClientEvent(parsed, userId, username, ws); handleClientEvent(parsed, userId, username, ws, isFederated);
} catch (err) { } catch (err) {
app.log.error({ err, eventType: parsed.type, userId }, 'Unhandled error in WS event handler'); app.log.error({ err, eventType: parsed.type, userId }, 'Unhandled error in WS event handler');
try { try {