FINAL: WebSocket + DMs + Files - Backend Complete!

WebSocket Real-Time:
- Socket.IO server integrated
- Real-time message delivery
- User online/offline status
- Typing indicators
- Channel room management
- Auto-join on channel access

Direct Messages:
- 1-on-1 chat API
- DM history and conversations
- @grimlock in DMs (AI responds)
- Read receipts
- Unread count tracking
- WebSocket notifications

File Management:
- Upload files to channels
- Download with streaming
- File metadata tracking
- File listing by channel
- Delete with permissions

Integration:
- Messages broadcast via WebSocket
- DM notifications via WebSocket
- All APIs updated for real-time

BACKEND IS FEATURE COMPLETE!
- Auth 
- Channels 
- Messages 
- DMs 
- Files 
- WebSocket 
- @grimlock AI 

Ready for frontend development in next session!
This commit is contained in:
JA
2026-02-12 22:11:55 +00:00
parent bf1baaebae
commit af57352d2a
5 changed files with 626 additions and 4 deletions

View File

@@ -14,7 +14,11 @@ from core.models import Message, Channel, User, ChannelType
from core.ai_client import AIClient
from core.context_manager import ContextManager
from api.auth import get_current_user
from core.websocket import broadcast_new_message
import main
import logging
logger = logging.getLogger(__name__)
router = APIRouter()
@@ -178,6 +182,25 @@ async def send_message(
db.commit()
db.refresh(message)
# Broadcast via WebSocket
message_data = {
"id": message.id,
"content": message.content,
"is_ai_message": message.is_ai_message,
"user": {
"id": current_user.id,
"name": current_user.name,
"email": current_user.email,
"role": current_user.role.value,
"is_online": current_user.is_online
} if message.user else None,
"reply_to_message_id": message.reply_to_message_id,
"created_at": message.created_at.isoformat(),
"edited_at": message.edited_at.isoformat() if message.edited_at else None
}
await broadcast_new_message(channel_id, message_data)
# Check for @grimlock mention
if detect_grimlock_mention(message_data.content):
# Handle in background to not block response