mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-11 19:04:35 +00:00
168 lines
3.4 KiB
Protocol Buffer
168 lines
3.4 KiB
Protocol Buffer
syntax = "proto3";
|
|
|
|
package chat;
|
|
option go_package = "./proto;chat";
|
|
|
|
service Chat {
|
|
rpc Create(CreateRequest) returns (CreateResponse);
|
|
rpc History(HistoryRequest) returns (HistoryResponse);
|
|
rpc Send(SendRequest) returns (SendResponse);
|
|
rpc List(ListRequest) returns (ListResponse);
|
|
rpc Delete(DeleteRequest) returns (DeleteResponse);
|
|
rpc Join(JoinRequest) returns (stream JoinResponse);
|
|
rpc Invite(InviteRequest) returns (InviteResponse);
|
|
rpc Leave(LeaveRequest) returns (LeaveResponse);
|
|
rpc Kick(KickRequest) returns (KickResponse);
|
|
}
|
|
|
|
// Create a new chat room
|
|
message CreateRequest {
|
|
// name of the room
|
|
string name = 1;
|
|
// chat description
|
|
string description = 2;
|
|
// optional list of user ids
|
|
repeated string user_ids = 3;
|
|
// whether its a private room
|
|
bool private = 4;
|
|
}
|
|
|
|
message CreateResponse {
|
|
// the unique chat room
|
|
Room room = 1;
|
|
}
|
|
|
|
// List the messages in a chat
|
|
message HistoryRequest {
|
|
// the chat room id to get
|
|
string room_id = 1;
|
|
}
|
|
|
|
// HistoryResponse contains the historical messages in a chat
|
|
message HistoryResponse {
|
|
// messages in the chat room
|
|
repeated Message messages = 1;
|
|
}
|
|
|
|
// List available chats
|
|
message ListRequest {
|
|
// optional user id to filter by
|
|
string user_id = 1;
|
|
}
|
|
|
|
message ListResponse {
|
|
repeated Room rooms = 1;
|
|
}
|
|
|
|
// Delete a chat room
|
|
message DeleteRequest {
|
|
// the chat room id to delete
|
|
string room_id = 1;
|
|
}
|
|
|
|
message DeleteResponse {
|
|
Room room = 1;
|
|
}
|
|
|
|
|
|
// Connect to a chat to receive a stream of messages
|
|
// Send a message to a chat
|
|
message SendRequest {
|
|
// a client side id, should be validated by the server to make the request retry safe
|
|
string client = 1;
|
|
// id of the chat room the message is being sent to / from
|
|
string room_id = 2;
|
|
// id of the user who sent the message
|
|
string user_id = 3;
|
|
// subject of the message
|
|
string subject = 4;
|
|
// text of the message
|
|
string text = 5;
|
|
}
|
|
|
|
message SendResponse {
|
|
// the message which was created
|
|
Message message = 1;
|
|
}
|
|
|
|
// Join a chat room
|
|
message JoinRequest {
|
|
// chat room to join
|
|
string room_id = 1;
|
|
// user id joining
|
|
string user_id = 2;
|
|
}
|
|
|
|
message JoinResponse {
|
|
Message message = 1;
|
|
}
|
|
|
|
message Room {
|
|
// unique room id
|
|
string id = 1;
|
|
// name of the chat
|
|
string name = 2;
|
|
// description of the that
|
|
string description = 3;
|
|
// time of creation
|
|
string created_at = 4;
|
|
// list of users
|
|
repeated string user_ids = 5;
|
|
// whether its a private room
|
|
bool private = 6;
|
|
}
|
|
|
|
// Message sent to a chat
|
|
message Message {
|
|
// id of the message, allocated by the server
|
|
string id = 1;
|
|
// a client side id, should be validated by the server to make the request retry safe
|
|
string client = 2;
|
|
// id of the chat the message is being sent to / from
|
|
string room_id = 3;
|
|
// id of the user who sent the message
|
|
string user_id = 4;
|
|
// time the message was sent in RFC3339 format
|
|
string sent_at = 5;
|
|
// subject of the message
|
|
string subject = 6;
|
|
// text of the message
|
|
string text = 7;
|
|
}
|
|
|
|
// Leave a chat room
|
|
message LeaveRequest {
|
|
// the chat room id
|
|
string room_id = 1;
|
|
// the user id
|
|
string user_id = 2;
|
|
}
|
|
|
|
message LeaveResponse {
|
|
Room room = 1;
|
|
}
|
|
|
|
// Invite a user to a chat room
|
|
message InviteRequest {
|
|
// the room id
|
|
string room_id = 1;
|
|
// the user id
|
|
string user_id = 2;
|
|
}
|
|
|
|
message InviteResponse {
|
|
Room room = 1;
|
|
}
|
|
|
|
// Kick a user from a chat room
|
|
message KickRequest {
|
|
// the chat room id
|
|
string room_id = 1;
|
|
// the user id
|
|
string user_id = 2;
|
|
}
|
|
|
|
message KickResponse {
|
|
Room room = 1;
|
|
}
|