Files
contracts/proto/chat/chat.proto
Дмитрий 1e1f1ba663
All checks were successful
Publish / Publish Job (push) Successful in 2m22s
feat: add chat proto file
2026-04-17 21:22:47 +03:00

110 lines
3.1 KiB
Protocol Buffer
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
syntax = "proto3";
package chat.v1;
option go_package = "git.lendry.ru/lendry-erp/proto.git/go;pb";
service ChatService {
// Управление чатами
rpc CreateChat(CreateChatRequest) returns (CreateChatResponse);
rpc GetUserChats(GetUserChatsRequest) returns (GetUserChatsResponse);
rpc JoinChat(JoinChatRequest) returns (JoinChatResponse);
rpc LeaveChat(LeaveChatRequest) returns (LeaveChatResponse);
// Управление сообщениями (история)
rpc GetMessages(GetMessagesRequest) returns (GetMessagesResponse);
rpc SendMessage(SendMessageRequest) returns (MessageDto); // вызывается либо из Gateway (для фото/аудио), либо напрямую
rpc DeleteMessage(DeleteMessageRequest) returns (DeleteMessageResponse);
// Статусы
rpc MarkAsRead(MarkAsReadRequest) returns (MarkAsReadResponse);
}
// --- СТРУКТУРЫ ДАННЫХ --- //
message MessageDto {
string id = 1;
string chat_id = 2;
string sender_id = 3;
string type = 4; // TEXT, VOICE, VIDEO_NOTE, STICKER
string content = 5;
string metadata = 6; // JSON string
string reply_to_id = 7;
bool is_edited = 8;
string created_at = 9;
}
message ChatDto {
string id = 1;
string type = 2; // DIRECT, GROUP, CHANNEL
string title = 3;
string avatar_url = 4;
int32 unread_count = 5;
MessageDto last_message = 6; // Нужно для рендера списка чатов слева!
}
// --- ЗАПРОСЫ / ОТВЕТЫ --- //
message CreateChatRequest {
string creator_id = 1; // ID того кто создает
string type = 2; // GROUP, DIRECT, CHANNEL
string title = 3; // Имя (при type=GROUP|CHANNEL)
repeated string participant_ids = 4; // Кого сразу добавить (собеседник в личке или юзеры в группе)
}
message CreateChatResponse {
ChatDto chat = 1;
}
message GetUserChatsRequest {
string user_id = 1;
int32 offset = 2; // для пагинации (бесконечный скролл в левой панели)
int32 limit = 3;
}
message GetUserChatsResponse {
repeated ChatDto chats = 1;
}
message JoinChatRequest {
string user_id = 1;
string chat_id = 2; // либо join_hash
}
message JoinChatResponse { bool success = 1; }
message LeaveChatRequest {
string user_id = 1;
string chat_id = 2;
}
message LeaveChatResponse { bool success = 1; }
message GetMessagesRequest {
string user_id = 1;
string chat_id = 2;
int32 limit = 3;
string before_msg_id = 4; // курсорная пагинация, как в Telegram
}
message GetMessagesResponse {
repeated MessageDto messages = 1;
}
message SendMessageRequest {
string chat_id = 1;
string sender_id = 2;
string type = 3;
string content = 4;
string reply_to_id = 5;
}
message DeleteMessageRequest {
string user_id = 1;
string message_id = 2;
bool for_everyone = 3; // "Удалить для всех"
}
message DeleteMessageResponse { bool success = 1; }
message MarkAsReadRequest {
string user_id = 1;
string chat_id = 2;
string message_id = 3;
}
message MarkAsReadResponse { bool success = 1; }