195 lines
5.5 KiB
Protocol Buffer
195 lines
5.5 KiB
Protocol Buffer
syntax = "proto3";
|
||
|
||
package hyapp.activity.v1;
|
||
|
||
option go_package = "hyapp.local/api/proto/activity/v1;activityv1";
|
||
|
||
// RequestMeta 是 activity-service 内部 RPC 的最小追踪元信息。
|
||
message RequestMeta {
|
||
string request_id = 1;
|
||
string caller = 2;
|
||
string gateway_node_id = 3;
|
||
int64 sent_at_ms = 4;
|
||
string app_code = 5;
|
||
}
|
||
|
||
// PingActivityRequest 用于验证 activity-service gRPC 链路可用。
|
||
message PingActivityRequest {
|
||
RequestMeta meta = 1;
|
||
}
|
||
|
||
// PingActivityResponse 返回服务是否接受请求。
|
||
message PingActivityResponse {
|
||
bool ok = 1;
|
||
string node_id = 2;
|
||
}
|
||
|
||
// GetActivityStatusRequest 查询活动服务底座状态。
|
||
message GetActivityStatusRequest {
|
||
RequestMeta meta = 1;
|
||
string activity_id = 2;
|
||
}
|
||
|
||
// GetActivityStatusResponse 返回活动是否启用。
|
||
message GetActivityStatusResponse {
|
||
string activity_id = 1;
|
||
string status = 2;
|
||
}
|
||
|
||
// MessageTabSection 是 App 消息 tab 的一个分区摘要。
|
||
message MessageTabSection {
|
||
string section = 1;
|
||
string title = 2;
|
||
int64 unread_count = 3;
|
||
string source = 4;
|
||
}
|
||
|
||
// ListMessageTabsRequest 查询当前用户消息 tab 摘要。
|
||
message ListMessageTabsRequest {
|
||
RequestMeta meta = 1;
|
||
int64 user_id = 2;
|
||
}
|
||
|
||
// ListMessageTabsResponse 固定返回 user/system/activity 三个分区。
|
||
message ListMessageTabsResponse {
|
||
repeated MessageTabSection sections = 1;
|
||
}
|
||
|
||
// InboxMessage 是 system/activity 分区列表可展示的消息快照。
|
||
message InboxMessage {
|
||
string message_id = 1;
|
||
string section = 2;
|
||
string title = 3;
|
||
string summary = 4;
|
||
string body = 5;
|
||
string icon_url = 6;
|
||
string image_url = 7;
|
||
string action_type = 8;
|
||
string action_param = 9;
|
||
bool read = 10;
|
||
int64 sent_at_ms = 11;
|
||
}
|
||
|
||
// ListInboxMessagesRequest 按 section 和游标分页读取当前用户 inbox。
|
||
message ListInboxMessagesRequest {
|
||
RequestMeta meta = 1;
|
||
int64 user_id = 2;
|
||
string section = 3;
|
||
int32 page_size = 4;
|
||
string page_token = 5;
|
||
}
|
||
|
||
// ListInboxMessagesResponse 返回当前页列表和下一页不透明游标。
|
||
message ListInboxMessagesResponse {
|
||
string section = 1;
|
||
repeated InboxMessage items = 2;
|
||
string next_page_token = 3;
|
||
}
|
||
|
||
// MarkInboxMessageReadRequest 标记单条消息已读。
|
||
message MarkInboxMessageReadRequest {
|
||
RequestMeta meta = 1;
|
||
int64 user_id = 2;
|
||
string message_id = 3;
|
||
}
|
||
|
||
// MarkInboxMessageReadResponse 返回消息首次已读时间;重复请求不覆盖该时间。
|
||
message MarkInboxMessageReadResponse {
|
||
string message_id = 1;
|
||
bool read = 2;
|
||
int64 read_at_ms = 3;
|
||
}
|
||
|
||
// MarkInboxSectionReadRequest 标记一个 section 下当前可见未读消息全部已读。
|
||
message MarkInboxSectionReadRequest {
|
||
RequestMeta meta = 1;
|
||
int64 user_id = 2;
|
||
string section = 3;
|
||
}
|
||
|
||
// MarkInboxSectionReadResponse 返回本次实际变更的消息数量。
|
||
message MarkInboxSectionReadResponse {
|
||
string section = 1;
|
||
int64 read_count = 2;
|
||
}
|
||
|
||
// DeleteInboxMessageRequest 删除当前用户可见消息,删除是用户侧隐藏。
|
||
message DeleteInboxMessageRequest {
|
||
RequestMeta meta = 1;
|
||
int64 user_id = 2;
|
||
string message_id = 3;
|
||
}
|
||
|
||
// DeleteInboxMessageResponse 返回被隐藏的消息 ID。
|
||
message DeleteInboxMessageResponse {
|
||
string message_id = 1;
|
||
bool deleted = 2;
|
||
}
|
||
|
||
// CreateInboxMessageRequest 是生产者入箱命令;producer_event_id 是幂等键。
|
||
message CreateInboxMessageRequest {
|
||
RequestMeta meta = 1;
|
||
int64 target_user_id = 2;
|
||
string producer = 3;
|
||
string producer_event_id = 4;
|
||
string producer_event_type = 5;
|
||
string message_type = 6;
|
||
string aggregate_type = 7;
|
||
string aggregate_id = 8;
|
||
string template_id = 9;
|
||
string template_version = 10;
|
||
string title = 11;
|
||
string summary = 12;
|
||
string body = 13;
|
||
string icon_url = 14;
|
||
string image_url = 15;
|
||
string action_type = 16;
|
||
string action_param = 17;
|
||
int32 priority = 18;
|
||
int64 sent_at_ms = 19;
|
||
int64 expire_at_ms = 20;
|
||
string metadata_json = 21;
|
||
}
|
||
|
||
// CreateInboxMessageResponse 返回入箱结果;重复同一 producer_event_id 时 created=false。
|
||
message CreateInboxMessageResponse {
|
||
string message_id = 1;
|
||
bool created = 2;
|
||
}
|
||
|
||
// CreateFanoutJobRequest 创建后台 fanout 任务;command_id 是后台命令幂等键。
|
||
message CreateFanoutJobRequest {
|
||
RequestMeta meta = 1;
|
||
string command_id = 2;
|
||
string message_type = 3;
|
||
string target_scope = 4;
|
||
string target_filter_json = 5;
|
||
string template_snapshot_json = 6;
|
||
int32 batch_size = 7;
|
||
string created_by = 8;
|
||
}
|
||
|
||
// CreateFanoutJobResponse 返回 fanout job 幂等创建结果。
|
||
message CreateFanoutJobResponse {
|
||
string job_id = 1;
|
||
string status = 2;
|
||
bool created = 3;
|
||
}
|
||
|
||
// ActivityService 只暴露同步查询,不把事件消费伪装成 RPC。
|
||
service ActivityService {
|
||
rpc PingActivity(PingActivityRequest) returns (PingActivityResponse);
|
||
rpc GetActivityStatus(GetActivityStatusRequest) returns (GetActivityStatusResponse);
|
||
}
|
||
|
||
// MessageInboxService 拥有 App system/activity 个人 inbox 事实。
|
||
service MessageInboxService {
|
||
rpc ListMessageTabs(ListMessageTabsRequest) returns (ListMessageTabsResponse);
|
||
rpc ListInboxMessages(ListInboxMessagesRequest) returns (ListInboxMessagesResponse);
|
||
rpc MarkInboxMessageRead(MarkInboxMessageReadRequest) returns (MarkInboxMessageReadResponse);
|
||
rpc MarkInboxSectionRead(MarkInboxSectionReadRequest) returns (MarkInboxSectionReadResponse);
|
||
rpc DeleteInboxMessage(DeleteInboxMessageRequest) returns (DeleteInboxMessageResponse);
|
||
rpc CreateInboxMessage(CreateInboxMessageRequest) returns (CreateInboxMessageResponse);
|
||
rpc CreateFanoutJob(CreateFanoutJobRequest) returns (CreateFanoutJobResponse);
|
||
}
|