feat: Add presence heartbeat for Matrix online status

- matrix-gateway: POST /internal/matrix/presence/online endpoint
- usePresenceHeartbeat hook with activity tracking
- Auto away after 5 min inactivity
- Offline on page close/visibility change
- Integrated in MatrixChatRoom component
This commit is contained in:
Apple
2025-11-27 00:19:40 -08:00
parent 5bed515852
commit 3de3c8cb36
6371 changed files with 1317450 additions and 932 deletions

View File

@@ -0,0 +1,39 @@
/**
* Auth Middleware
* Validates Bearer token
* MVP: Simple validation, replace with proper JWT validation later
*/
import type { Request, Response, NextFunction } from 'express';
export function authMiddleware(req: Request, res: Response, next: NextFunction): void {
const authHeader = req.headers.authorization;
if (!authHeader || !authHeader.startsWith('Bearer ')) {
res.status(401).json({
error: 'UNAUTHORIZED',
message: 'Missing or invalid Authorization header',
});
return;
}
const token = authHeader.substring(7);
// MVP: Simple validation (just check token exists)
// TODO: Validate JWT token properly
if (!token) {
res.status(401).json({
error: 'UNAUTHORIZED',
message: 'Invalid token',
});
return;
}
// Attach user ID to request (MVP: extract from token)
// TODO: Decode JWT and extract userId
(req as any).userId = 'user_stub'; // Replace with actual user ID from token
next();
}