mirror of
https://github.com/fromchat-messenger/web.git
synced 2026-09-22 11:05:05 +03:00
Fix WebSocket
This commit is contained in:
@@ -119,10 +119,6 @@ async def register(request: Request):
|
||||
"""Register endpoint - routes to account service."""
|
||||
return await _proxy_to_service("account", "register", request)
|
||||
|
||||
@app.api_route("/chat/ws", methods=["GET"])
|
||||
async def chat_websocket(request: Request):
|
||||
"""Chat WebSocket endpoint - routes to messaging service."""
|
||||
return await _proxy_to_service("messaging", "chat/ws", request)
|
||||
|
||||
# API routes - route to appropriate microservices
|
||||
@app.api_route("/account/{path:path}", methods=["GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS", "HEAD"])
|
||||
|
||||
@@ -1292,7 +1292,7 @@ class MessaggingSocketManager:
|
||||
self.ws_subscriptions[websocket] = set()
|
||||
|
||||
# Import here to avoid circular import
|
||||
from websocket.handlers import handler_registry
|
||||
from backend.services.messaging.files.websocket.handlers import handler_registry
|
||||
|
||||
while True:
|
||||
try:
|
||||
|
||||
@@ -6,8 +6,8 @@ from typing import Any
|
||||
from fastapi import HTTPException, WebSocket, Request
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from websocket.registry import WebSocketHandlerRegistry
|
||||
from routes.messaging import (
|
||||
from backend.services.messaging.files.websocket.registry import WebSocketHandlerRegistry
|
||||
from backend.routes.messaging import (
|
||||
MessaggingSocketManager,
|
||||
_send_message_internal,
|
||||
_edit_message_internal,
|
||||
@@ -17,7 +17,7 @@ from routes.messaging import (
|
||||
add_reaction,
|
||||
add_dm_reaction,
|
||||
)
|
||||
from models import (
|
||||
from backend.shared.models import (
|
||||
User,
|
||||
SendMessageRequest,
|
||||
EditMessageRequest,
|
||||
@@ -26,7 +26,7 @@ from models import (
|
||||
DMReactionRequest,
|
||||
UpdateLog,
|
||||
)
|
||||
from security.audit import log_access, log_dm
|
||||
from backend.security.audit import log_access, log_dm
|
||||
|
||||
logger = logging.getLogger("uvicorn.error")
|
||||
|
||||
|
||||
@@ -16,7 +16,13 @@ app.use('/api', createProxyMiddleware({
|
||||
ws: true
|
||||
}));
|
||||
|
||||
// WebSockets are handled by the general API proxy above
|
||||
// Direct WebSocket proxy for chat - bypass gateway
|
||||
app.use('/api/chat/ws', createProxyMiddleware({
|
||||
target: 'http://messaging_service:8305',
|
||||
changeOrigin: true,
|
||||
pathRewrite: { '^/api/chat/ws': '/messaging/chat/ws' },
|
||||
ws: true
|
||||
}));
|
||||
|
||||
// Serve static files
|
||||
app.use(express.static(resolve(filePath)));
|
||||
|
||||
Reference in New Issue
Block a user