import type { Request, Response } from 'express';
import DirectMessagesService from '@/services/direct_messages';

export async function contacts(req: Request, res: Response): Promise<void> {
  const payload = await DirectMessagesService.contacts(req.currentUser);
  res.status(200).send(payload);
}

export async function conversations(req: Request, res: Response): Promise<void> {
  const payload = await DirectMessagesService.conversations(req.currentUser);
  res.status(200).send(payload);
}

export async function thread(req: Request, res: Response): Promise<void> {
  const payload = await DirectMessagesService.thread(
    req.params.otherUserId,
    req.query.studentId,
    req.currentUser,
  );
  res.status(200).send(payload);
}

export async function send(req: Request, res: Response): Promise<void> {
  const payload = await DirectMessagesService.send(req.body.data, req.currentUser);
  res.status(200).send(payload);
}
