Skip to main content

Chat Feature Reference

Frontend modules

  • frontend/src/components/ChatList/index.js:8 renders the left rail of conversations and calls setCurrentChat when a user picks one.
  • frontend/src/components/ChatWindow/index.js:73 loads history with getMessages(chatId, token, page) and pushes new messages via sendMessage at line 240.
  • Utility hooks listen for socket.io events declared in frontend/src/_helper/ChatSocketListener.js, incrementing unread counts unless the active chat matches the payload.

API layer

  • frontend/src/api/chatApi.js:8 defines GET /chat for the user�s chat roster, GET /chat/{chatId} for message history, and POST /chat/send/{chatId} for outbound messages.
  • Additional helpers cover unread counts (GET /chat/unread-count), request management (POST /chat/req/{uid}, /chat/acp/{chatId}, /chat/dec/{chatId}) and moderation (POST /chat/block/{chatId} / unblock).

Backend status

  • Routes are prepared in backend/r/chat.js, but they are currently commented out pending infrastructure enablement; toggling chat requires re-enabling this router in server.js.
  • The associated controller (backend/controllers/chatController.js) already implements request acceptance, messaging, and unread counters backed by PostgreSQL and Redis.

Operational notes

  • Because the HTTP endpoints are inactive by default, the frontend gracefully falls back to �Chat not found� (frontend/src/components/ChatWindow/index.js:176) when responses fail.
  • Chat sockets use room names matching chat_id; reconnections re-join all active rooms by iterating over getChatUsers.
  • When enabling chat server-side, ensure CORS and rate-limit settings match the rest of the API�we share the same cookie and session configuration.