feat: add chat proto file
All checks were successful
Publish / Publish Job (push) Successful in 2m22s
All checks were successful
Publish / Publish Job (push) Successful in 2m22s
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@lendry-erp/contracts",
|
"name": "@lendry-erp/contracts",
|
||||||
"version": "1.2.27",
|
"version": "1.2.28",
|
||||||
"description": "Protobuf definitions and generated TypeScript types",
|
"description": "Protobuf definitions and generated TypeScript types",
|
||||||
"type": "commonjs",
|
"type": "commonjs",
|
||||||
"main": "./dist/index.js",
|
"main": "./dist/index.js",
|
||||||
|
|||||||
109
proto/chat/chat.proto
Normal file
109
proto/chat/chat.proto
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
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; }
|
||||||
@@ -15,4 +15,5 @@ export const PROTO_PATHS = {
|
|||||||
__dirname,
|
__dirname,
|
||||||
"../../proto/notifications/notifications.proto",
|
"../../proto/notifications/notifications.proto",
|
||||||
),
|
),
|
||||||
|
CHAT: join(__dirname, "../../proto/chat/chat.proto"),
|
||||||
} as const;
|
} as const;
|
||||||
|
|||||||
Reference in New Issue
Block a user