mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-16 04:54:42 +00:00
79 lines
1.8 KiB
Protocol Buffer
79 lines
1.8 KiB
Protocol Buffer
syntax = "proto3";
|
|
|
|
package chats;
|
|
|
|
option go_package = "./proto;chats";
|
|
|
|
service Chats {
|
|
// Create a chat between two or more users, if a chat already exists for these users, the existing
|
|
// chat will be returned
|
|
rpc CreateChat(CreateChatRequest) returns (CreateChatResponse);
|
|
// Create a message within a chat
|
|
rpc SendMessage(SendMessageRequest) returns (SendMessageResponse);
|
|
// List the messages within a chat in reverse chronological order, using sent_before to
|
|
// offset as older messages need to be loaded
|
|
rpc ListMessages(ListMessagesRequest) returns (ListMessagesResponse);
|
|
}
|
|
|
|
message Chat {
|
|
// unique id of the chat
|
|
string id = 1;
|
|
// list of users in the chat
|
|
repeated string user_ids = 2;
|
|
// RFC3339 Nano timestamp e.g 2006-01-02T15:04:05.999999999Z07:00
|
|
string created_at = 3;
|
|
}
|
|
|
|
message Message {
|
|
// unique id of the message
|
|
string id = 1;
|
|
// user id of the message
|
|
string author_id = 2;
|
|
// chat id the message belongs to
|
|
string chat_id = 3;
|
|
// text within the message
|
|
string text = 4;
|
|
// RFC3339 Nano timestamp e.g 2006-01-02T15:04:05.999999999Z07:00
|
|
string sent_at = 5;
|
|
}
|
|
|
|
// Create a new chat between mulitple users
|
|
message CreateChatRequest {
|
|
// The chat ID
|
|
string id = 1;
|
|
// List of users in the chat
|
|
repeated string user_ids = 2;
|
|
}
|
|
|
|
message CreateChatResponse {
|
|
Chat chat = 1;
|
|
}
|
|
|
|
// Send a message to a chat room
|
|
message SendMessageRequest {
|
|
string id = 1;
|
|
string chat_id = 2;
|
|
string author_id = 3;
|
|
string text = 4;
|
|
}
|
|
|
|
message SendMessageResponse {
|
|
Message message = 1;
|
|
}
|
|
|
|
// List messages within a chat
|
|
message ListMessagesRequest {
|
|
// unique id of the chat
|
|
string chat_id = 1;
|
|
// limit the number of messages
|
|
int64 limit = 2;
|
|
// offset for the messages
|
|
int64 offset = 3;
|
|
// order "asc" or "desc" (defaults to reverse chronological)
|
|
string order = 4;
|
|
}
|
|
|
|
message ListMessagesResponse {
|
|
repeated Message messages = 1;
|
|
}
|