154 lines
5.1 KiB
Protocol Buffer
154 lines
5.1 KiB
Protocol Buffer
syntax = "proto3";
|
||
|
||
package proto;
|
||
|
||
option go_package = ".;proto";
|
||
|
||
// Сервис для работы с подписками
|
||
service SubscribeService {
|
||
// Подписаться на пользователя
|
||
rpc FollowUser (FollowRequest) returns (FollowResponse);
|
||
|
||
// Отписаться от пользователя
|
||
rpc UnfollowUser (UnfollowRequest) returns (UnfollowResponse);
|
||
|
||
// Получить список подписчиков пользователя
|
||
rpc GetFollowers (GetFollowersRequest) returns (GetFollowersResponse);
|
||
|
||
// Получить список подписок пользователя
|
||
rpc GetFollowing (GetFollowingRequest) returns (GetFollowingResponse);
|
||
|
||
// Проверить, подписан ли пользователь на другого
|
||
rpc IsFollowing (IsFollowingRequest) returns (IsFollowingResponse);
|
||
|
||
// Получить уведомления о подписках для пользователя
|
||
rpc GetSubscriptionNotifications (GetNotificationsRequest) returns (GetNotificationsResponse);
|
||
|
||
// Пометить уведомление как прочитанное
|
||
rpc MarkNotificationAsRead (MarkNotificationReadRequest) returns (MarkNotificationReadResponse);
|
||
|
||
// Получить только КОЛИЧЕСТВО подписчиков
|
||
rpc GetFollowersCount (GetCountRequest) returns (GetCountResponse);
|
||
|
||
// Получить только КОЛИЧЕСТВО подписок
|
||
rpc GetFollowingCount (GetCountRequest) returns (GetCountResponse);
|
||
}
|
||
|
||
message GetCountRequest {
|
||
int32 user_id = 1;
|
||
}
|
||
|
||
// Ответ с количеством
|
||
message GetCountResponse {
|
||
int32 count = 1;
|
||
}
|
||
|
||
// Запрос на подписку
|
||
message FollowRequest {
|
||
int32 follower_id = 1; // ID пользователя, который подписывается
|
||
int32 following_id = 2; // ID пользователя, на которого подписываются
|
||
}
|
||
|
||
// Ответ на подписку
|
||
message FollowResponse {
|
||
bool success = 1; // Успешность операции
|
||
string message = 2; // Сообщение (например, об ошибке)
|
||
int32 subscription_id = 3; // ID созданной подписки
|
||
int32 notification_id = 4; // ID созданного уведомления
|
||
}
|
||
|
||
// Запрос на отписку
|
||
message UnfollowRequest {
|
||
int32 follower_id = 1;
|
||
int32 following_id = 2;
|
||
}
|
||
|
||
// Ответ на отписку
|
||
message UnfollowResponse {
|
||
bool success = 1;
|
||
string message = 2;
|
||
}
|
||
|
||
// Запрос на получение подписчиков
|
||
message GetFollowersRequest {
|
||
int32 user_id = 1; // ID пользователя, чьих подписчиков запрашиваем
|
||
int32 limit = 2; // Лимит (для пагинации)
|
||
int32 offset = 3; // Смещение (для пагинации)
|
||
}
|
||
|
||
// Ответ с подписчиками
|
||
message GetFollowersResponse {
|
||
repeated Follower followers = 1; // Список подписчиков
|
||
int32 total_count = 2; // Общее количество подписчиков
|
||
message Follower {
|
||
int32 user_id = 1;
|
||
string username = 2;
|
||
string avatar = 3;
|
||
}
|
||
}
|
||
|
||
// Запрос на получение подписок
|
||
message GetFollowingRequest {
|
||
int32 user_id = 1; // ID пользователя, чьи подписки запрашиваем
|
||
int32 limit = 2;
|
||
int32 offset = 3;
|
||
}
|
||
|
||
// Ответ с подписками
|
||
message GetFollowingResponse {
|
||
repeated Following following = 1; // Список подписок
|
||
int32 total_count = 2; // Общее количество подписок
|
||
message Following {
|
||
int32 user_id = 1;
|
||
string username = 2;
|
||
string avatar = 3;
|
||
}
|
||
}
|
||
|
||
// Запрос на проверку подписки
|
||
message IsFollowingRequest {
|
||
int32 follower_id = 1;
|
||
int32 following_id = 2;
|
||
}
|
||
|
||
// Ответ на проверку подписки
|
||
message IsFollowingResponse {
|
||
bool is_following = 1; // true - подписан, false - не подписан
|
||
}
|
||
|
||
// Запрос на получение уведомлений
|
||
message GetNotificationsRequest {
|
||
int32 user_id = 1; // ID пользователя, чьи уведомления запрашиваем
|
||
bool unread_only = 2; // Только непрочитанные
|
||
int32 limit = 3;
|
||
int32 offset = 4;
|
||
}
|
||
|
||
// Ответ с уведомлениями
|
||
message GetNotificationsResponse {
|
||
repeated Notification notifications = 1;
|
||
int32 total_count = 2;
|
||
int32 unread_count = 3; // Количество непрочитанных уведомлений
|
||
message Notification {
|
||
int32 id = 1;
|
||
int32 subscription_id = 2;
|
||
int32 follower_id = 3;
|
||
string follower_username = 4;
|
||
string follower_avatar = 5;
|
||
bool is_read = 6;
|
||
string created_at = 7;
|
||
string expires_at = 8;
|
||
}
|
||
}
|
||
|
||
// Запрос на пометку уведомления как прочитанного
|
||
message MarkNotificationReadRequest {
|
||
int32 notification_id = 1;
|
||
int32 user_id = 2; // Для проверки прав
|
||
}
|
||
|
||
// Ответ на пометку уведомления
|
||
message MarkNotificationReadResponse {
|
||
bool success = 1;
|
||
string message = 2;
|
||
} |