import { Response } from 'express'; import { SendMessageDTO, CreateEventDTO } from '@caldav/shared'; import { ChatService } from '../services'; import { AuthenticatedRequest } from '../middleware'; export class ChatController { constructor(private chatService: ChatService) {} async sendMessage(req: AuthenticatedRequest, res: Response): Promise { try { const userId = req.user!.userId; const data: SendMessageDTO = req.body; const response = await this.chatService.processMessage(userId, data); res.json(response); } catch (error) { res.status(500).json({ error: 'Failed to process message' }); } } async confirmEvent(req: AuthenticatedRequest, res: Response): Promise { try { const userId = req.user!.userId; const { conversationId, messageId } = req.params; const event: CreateEventDTO = req.body; const response = await this.chatService.confirmEvent(userId, conversationId, messageId, event); res.json(response); } catch (error) { res.status(500).json({ error: 'Failed to confirm event' }); } } async rejectEvent(req: AuthenticatedRequest, res: Response): Promise { try { const userId = req.user!.userId; const { conversationId, messageId } = req.params; const response = await this.chatService.rejectEvent(userId, conversationId, messageId); res.json(response); } catch (error) { res.status(500).json({ error: 'Failed to reject event' }); } } async getConversations(req: AuthenticatedRequest, res: Response): Promise { throw new Error('Not implemented'); } async getConversation(req: AuthenticatedRequest, res: Response): Promise { throw new Error('Not implemented'); } }