import { Router } from "express";
import { checkAuth } from "../middleware/checkAuth";
import {
  createOrGetConversation,
  getConversations,
  getConversationMessages,
  uploadChatMedia,
  markConversationAsRead,
} from "../controllers/chatController";
import { handleChatMediaLocal } from "../utils/Mutlipart";

const router = Router();

router.post("/conversations", checkAuth, createOrGetConversation);
router.get("/conversations", checkAuth, getConversations);
router.get(
  "/conversations/:conversationId/messages",
  checkAuth,
  getConversationMessages,
);
router.post(
  "/conversations/:conversationId/read",
  checkAuth,
  markConversationAsRead,
);
router.post(
  "/upload",
  checkAuth,
  handleChatMediaLocal.array("media", 10),
  uploadChatMedia,
);

export default router;
