255 lines
5.4 KiB
Protocol Buffer
255 lines
5.4 KiB
Protocol Buffer
syntax = "proto3";
|
|
|
|
package message;
|
|
|
|
option go_package = "git.madsky.ru/lotti/message/pkg/messages/message";
|
|
|
|
import "google/protobuf/empty.proto";
|
|
import "validate/validate.proto";
|
|
|
|
service MessageService {
|
|
|
|
rpc CreateUser(CreateUserRequest) returns(CreateUserResponse);
|
|
rpc UpdateUser(UpdateUserRequest) returns(UpdateUserResponse);
|
|
rpc GetUserByToken(GetUserByTokenRequest) returns(GetUserResponse);
|
|
rpc GetUserByEmail(GetUserByEmailRequest) returns(GetUserResponse);
|
|
rpc ListUser(ListUserRequest) returns(ListUserResponse);
|
|
rpc GetUser(GetUserRequest) returns(GetUserResponse);
|
|
|
|
rpc CreateChat(CreateChatRequest) returns(CreateChatResponse);
|
|
rpc UpdateChat(UpdateChatRequest) returns(UpdateChatResponse);
|
|
rpc GetChat(GetChatRequest) returns(GetChatResponse);
|
|
rpc ListChat(ListChatRequest) returns(ListChatResponse);
|
|
|
|
rpc CreateMessage(CreateMessageRequest) returns(CreateMessageResponse);
|
|
rpc UpdateMessage(UpdateMessageRequest) returns(UpdateMessageResponse);
|
|
rpc GetMessage(GetMessageRequest) returns(GetMessageResponse);
|
|
rpc ListMessage(ListMessageRequest) returns(ListMessageResponse);
|
|
|
|
rpc GetVersion(google.protobuf.Empty) returns(GetVersionResponse);
|
|
}
|
|
|
|
// User
|
|
message CreateUserRequest {
|
|
string email = 1 [(validate.rules).string.email = true];
|
|
optional string name = 2 [(validate.rules).string = {
|
|
ignore_empty: true, // ⭐ Главное правило
|
|
max_len: 200
|
|
}];
|
|
}
|
|
|
|
message CreateUserResponse {
|
|
User data = 1;
|
|
}
|
|
|
|
message UpdateUserRequest {
|
|
int32 id = 1 [(validate.rules).int32.gt = 0];
|
|
optional string token = 2; // todo
|
|
optional string description = 3 [(validate.rules).string = {
|
|
ignore_empty: true,
|
|
max_len: 200
|
|
}];
|
|
}
|
|
|
|
message UpdateUserResponse {
|
|
User data = 1;
|
|
}
|
|
|
|
message GetUserByTokenRequest {
|
|
string token = 1; // todo
|
|
}
|
|
|
|
message GetUserByEmailRequest {
|
|
string email = 1 [(validate.rules).string.email = true];
|
|
}
|
|
|
|
message GetUserRequest {
|
|
int32 id = 1 [(validate.rules).int32.gt = 0];
|
|
}
|
|
|
|
message GetUserResponse {
|
|
User data = 1;
|
|
}
|
|
|
|
message ListUserRequest {
|
|
int32 page = 1;
|
|
repeated int32 user_ids = 2;
|
|
}
|
|
|
|
message ListUserResponse {
|
|
repeated User data = 1;
|
|
}
|
|
|
|
message User {
|
|
int32 id = 1;
|
|
optional string token = 2;
|
|
string email = 3;
|
|
optional string description = 4;
|
|
optional string name = 5;
|
|
}
|
|
|
|
message UserForChatResponse {
|
|
int32 id = 1;
|
|
optional string token = 2;
|
|
string email = 3;
|
|
optional string description = 4;
|
|
optional bool is_admin = 5;
|
|
optional string name = 6;
|
|
}
|
|
|
|
// User end
|
|
|
|
// Chat
|
|
message CreateChatRequest {
|
|
optional string name = 1;
|
|
repeated UserForChat users = 2 [(validate.rules).repeated = {
|
|
min_items: 1,
|
|
}];
|
|
}
|
|
|
|
message UserForChat {
|
|
int32 user_id = 1 [(validate.rules).int32.gt = 0];
|
|
optional bool is_admin = 2;
|
|
}
|
|
|
|
message CreateChatResponse {
|
|
Chat data = 1;
|
|
}
|
|
|
|
message UpdateChatRequest {
|
|
string id = 1 [(validate.rules).string = {
|
|
uuid: true,
|
|
}];
|
|
repeated UserForChat users = 2 [(validate.rules).repeated = {
|
|
min_items: 1,
|
|
}];
|
|
}
|
|
|
|
message UpdateChatResponse {
|
|
Chat data = 1;
|
|
}
|
|
|
|
message GetChatRequest {
|
|
string id = 1 [(validate.rules).string = {
|
|
uuid: true,
|
|
}];
|
|
}
|
|
|
|
message GetChatResponse {
|
|
Chat data = 1;
|
|
}
|
|
|
|
message ListChatRequest {
|
|
int32 page = 1;
|
|
int32 user_id = 2 [(validate.rules).int32.gt = 0];
|
|
}
|
|
|
|
message ListChatResponse {
|
|
repeated Chat data = 1;
|
|
}
|
|
|
|
message Chat {
|
|
string id = 1;
|
|
int32 type_id = 2;
|
|
optional string name = 3;
|
|
repeated UserForChatResponse users = 4;
|
|
}
|
|
// Chat end
|
|
|
|
// Message
|
|
message CreateMessageRequest {
|
|
string chat_id = 2 [(validate.rules).string = {
|
|
uuid: true,
|
|
}];
|
|
int32 user_id = 3 [(validate.rules).int32.gt = 0];
|
|
optional string text = 4 [(validate.rules).string = {
|
|
ignore_empty: true,
|
|
max_len: 200
|
|
}];
|
|
optional string image = 5 [(validate.rules).string = {
|
|
ignore_empty: true,
|
|
max_len: 200
|
|
}];
|
|
optional string video = 6 [(validate.rules).string = {
|
|
ignore_empty: true,
|
|
max_len: 200
|
|
}];
|
|
optional string file = 7 [(validate.rules).string = {
|
|
ignore_empty: true,
|
|
max_len: 200
|
|
}];
|
|
}
|
|
|
|
message CreateMessageResponse {
|
|
Message data = 1;
|
|
}
|
|
|
|
message UpdateMessageRequest {
|
|
int32 id = 1 [(validate.rules).int32.gt = 0];
|
|
string chat_id = 2 [(validate.rules).string = {
|
|
uuid: true,
|
|
}];
|
|
optional string text = 3 [(validate.rules).string = {
|
|
ignore_empty: true,
|
|
max_len: 200
|
|
}];
|
|
optional string image = 4 [(validate.rules).string = {
|
|
ignore_empty: true,
|
|
max_len: 200
|
|
}];
|
|
optional string video = 5 [(validate.rules).string = {
|
|
ignore_empty: true,
|
|
max_len: 200
|
|
}];
|
|
optional string file = 6 [(validate.rules).string = {
|
|
ignore_empty: true,
|
|
max_len: 200
|
|
}];
|
|
}
|
|
|
|
message UpdateMessageResponse {
|
|
Message data = 1;
|
|
}
|
|
|
|
message GetMessageRequest {
|
|
int32 id = 1 [(validate.rules).int32.gt = 0];
|
|
}
|
|
|
|
message GetMessageResponse {
|
|
Message data = 1;
|
|
}
|
|
|
|
message ListMessageRequest {
|
|
int32 page = 1;
|
|
string chat_id = 2 [(validate.rules).string = {
|
|
uuid: true,
|
|
}];
|
|
int32 user_id = 3 [(validate.rules).int32.gt = 0];
|
|
}
|
|
|
|
message ListMessageResponse {
|
|
repeated Message data = 1;
|
|
}
|
|
message Message {
|
|
int32 id = 1;
|
|
int32 user_id = 2;
|
|
optional string text = 3;
|
|
optional string image = 4;
|
|
optional string video = 5;
|
|
optional string file = 6;
|
|
string created_at = 7;
|
|
string updated_at = 8;
|
|
}
|
|
|
|
// Message end
|
|
|
|
// Version
|
|
message GetVersionResponse {
|
|
Version data = 1;
|
|
}
|
|
|
|
message Version {
|
|
int32 id = 1;
|
|
string version = 2;
|
|
}
|
|
// Version end |