feat: implement messaging functionality with real-time updates

- Introduced a messaging module on the backend using NestJS, including repository, service, controller, DTOs, and WebSocket Gateway.
- Developed a frontend messaging page with conversation management, real-time message handling, and chat UI.
- Implemented `MessageService` for API integrations and `SocketProvider` for real-time WebSocket updates.
- Enhanced database schema to support conversations, participants, and messages with Drizzle ORM.
This commit is contained in:
Mathis HERRIOT
2026-01-29 14:34:22 +01:00
parent 01117aad6d
commit fafdaee668
13 changed files with 995 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
import api from "@/lib/api";
export interface Comment {
id: string;
text: string;
createdAt: string;
updatedAt: string;
user: {
uuid: string;
username: string;
displayName?: string;
avatarUrl?: string;
};
}
export const CommentService = {
async getByContentId(contentId: string): Promise<Comment[]> {
const { data } = await api.get<Comment[]>(`/contents/${contentId}/comments`);
return data;
},
async create(contentId: string, text: string): Promise<Comment> {
const { data } = await api.post<Comment>(`/contents/${contentId}/comments`, {
text,
});
return data;
},
async remove(commentId: string): Promise<void> {
await api.delete(`/comments/${commentId}`);
},
};

View File

@@ -0,0 +1,44 @@
import api from "@/lib/api";
export interface Conversation {
id: string;
updatedAt: string;
lastMessage?: {
text: string;
createdAt: string;
};
recipient: {
uuid: string;
username: string;
displayName?: string;
avatarUrl?: string;
};
}
export interface Message {
id: string;
text: string;
createdAt: string;
senderId: string;
readAt?: string;
}
export const MessageService = {
async getConversations(): Promise<Conversation[]> {
const { data } = await api.get<Conversation[]>("/messages/conversations");
return data;
},
async getMessages(conversationId: string): Promise<Message[]> {
const { data } = await api.get<Message[]>(`/messages/conversations/${conversationId}`);
return data;
},
async sendMessage(recipientId: string, text: string): Promise<Message> {
const { data } = await api.post<Message>("/messages", {
recipientId,
text,
});
return data;
},
};