596 lines
17 KiB
Protocol Buffer
596 lines
17 KiB
Protocol Buffer
syntax = "proto3";
|
||
|
||
package hyapp.activity.v1;
|
||
|
||
import "proto/events/room/v1/events.proto";
|
||
|
||
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;
|
||
}
|
||
|
||
// CronBatchRequest 是 cron-service 触发 activity-service 后台批处理的统一请求。
|
||
message CronBatchRequest {
|
||
RequestMeta meta = 1;
|
||
string run_id = 2;
|
||
string worker_id = 3;
|
||
int32 batch_size = 4;
|
||
int64 lock_ttl_ms = 5;
|
||
}
|
||
|
||
// CronBatchResponse 返回一个批处理 run 的执行摘要。
|
||
message CronBatchResponse {
|
||
int32 claimed_count = 1;
|
||
int32 processed_count = 2;
|
||
int32 success_count = 3;
|
||
int32 failure_count = 4;
|
||
bool has_more = 5;
|
||
}
|
||
|
||
// TaskItem 是 App 每日任务/专属任务列表里的单个可展示任务快照。
|
||
message TaskItem {
|
||
string task_id = 1;
|
||
string task_type = 2;
|
||
string category = 3;
|
||
string metric_type = 4;
|
||
string title = 5;
|
||
string description = 6;
|
||
int64 target_value = 7;
|
||
string target_unit = 8;
|
||
int64 progress_value = 9;
|
||
int64 reward_coin_amount = 10;
|
||
string status = 11;
|
||
bool claimable = 12;
|
||
string task_day = 13;
|
||
int64 server_time_ms = 14;
|
||
int64 next_refresh_at_ms = 15;
|
||
int32 sort_order = 16;
|
||
int64 version = 17;
|
||
}
|
||
|
||
// TaskSection 固定表达 App 任务页的 daily/exclusive 两个分区。
|
||
message TaskSection {
|
||
string section = 1;
|
||
repeated TaskItem items = 2;
|
||
int64 server_time_ms = 3;
|
||
int64 next_refresh_at_ms = 4;
|
||
}
|
||
|
||
// ListUserTasksRequest 查询当前用户任务进度;进度必须来自服务端事实事件。
|
||
message ListUserTasksRequest {
|
||
RequestMeta meta = 1;
|
||
int64 user_id = 2;
|
||
}
|
||
|
||
// ListUserTasksResponse 返回 daily/exclusive 分区和服务器刷新时间。
|
||
message ListUserTasksResponse {
|
||
repeated TaskSection sections = 1;
|
||
int64 server_time_ms = 2;
|
||
int64 next_refresh_at_ms = 3;
|
||
}
|
||
|
||
// ClaimTaskRewardRequest 领取已完成任务奖励;command_id 是领奖幂等键。
|
||
message ClaimTaskRewardRequest {
|
||
RequestMeta meta = 1;
|
||
int64 user_id = 2;
|
||
string task_id = 3;
|
||
string task_type = 4;
|
||
string task_day = 5;
|
||
string command_id = 6;
|
||
}
|
||
|
||
// ClaimTaskRewardResponse 返回 activity 领奖状态和 wallet 入账回执。
|
||
message ClaimTaskRewardResponse {
|
||
string claim_id = 1;
|
||
string task_id = 2;
|
||
string task_type = 3;
|
||
string task_day = 4;
|
||
int64 reward_coin_amount = 5;
|
||
string status = 6;
|
||
string wallet_transaction_id = 7;
|
||
int64 granted_at_ms = 8;
|
||
bool claimed = 9;
|
||
}
|
||
|
||
// ConsumeTaskEventRequest 是异步 outbox consumer 投递给任务系统的事实事件。
|
||
message ConsumeTaskEventRequest {
|
||
RequestMeta meta = 1;
|
||
string event_id = 2;
|
||
string event_type = 3;
|
||
string source_service = 4;
|
||
int64 user_id = 5;
|
||
string metric_type = 6;
|
||
int64 value = 7;
|
||
int64 occurred_at_ms = 8;
|
||
}
|
||
|
||
// ConsumeTaskEventResponse 返回事件消费幂等结果;matched_task_count=0 表示合法跳过。
|
||
message ConsumeTaskEventResponse {
|
||
string event_id = 1;
|
||
string status = 2;
|
||
int32 matched_task_count = 3;
|
||
}
|
||
|
||
// BroadcastJoinGroup 是 gateway 下发给客户端的 IM 播报群信息在服务端的同源结构。
|
||
message BroadcastJoinGroup {
|
||
string group_id = 1;
|
||
string type = 2;
|
||
int64 region_id = 3;
|
||
}
|
||
|
||
message EnsureBroadcastGroupsRequest {
|
||
RequestMeta meta = 1;
|
||
}
|
||
|
||
message EnsureBroadcastGroupsResponse {
|
||
int32 ensured_count = 1;
|
||
}
|
||
|
||
message PublishRegionBroadcastRequest {
|
||
RequestMeta meta = 1;
|
||
string event_id = 2;
|
||
int64 region_id = 3;
|
||
string broadcast_type = 4;
|
||
string payload_json = 5;
|
||
}
|
||
|
||
message PublishGlobalBroadcastRequest {
|
||
RequestMeta meta = 1;
|
||
string event_id = 2;
|
||
string broadcast_type = 3;
|
||
string payload_json = 4;
|
||
}
|
||
|
||
message PublishBroadcastResponse {
|
||
string event_id = 1;
|
||
string group_id = 2;
|
||
string status = 3;
|
||
bool created = 4;
|
||
}
|
||
|
||
// RemoveRegionBroadcastMemberRequest 只移除某个用户的旧区域群成员关系,不删除或解散区域群。
|
||
message RemoveRegionBroadcastMemberRequest {
|
||
RequestMeta meta = 1;
|
||
int64 user_id = 2;
|
||
int64 region_id = 3;
|
||
string reason = 4;
|
||
}
|
||
|
||
message RemoveRegionBroadcastMemberResponse {
|
||
string group_id = 1;
|
||
bool removed = 2;
|
||
}
|
||
|
||
message ProcessBroadcastOutboxBatchResponse {
|
||
int32 claimed_count = 1;
|
||
int32 success_count = 2;
|
||
int32 failure_count = 3;
|
||
bool has_more = 4;
|
||
}
|
||
|
||
message ConsumeRoomEventRequest {
|
||
RequestMeta meta = 1;
|
||
hyapp.events.room.v1.EventEnvelope envelope = 2;
|
||
}
|
||
|
||
message ConsumeRoomEventResponse {
|
||
string event_id = 1;
|
||
string status = 2;
|
||
string broadcast_event_id = 3;
|
||
bool broadcast_created = 4;
|
||
}
|
||
|
||
// TaskDefinition 是后台管理任务配置的当前版本读模型。
|
||
message TaskDefinition {
|
||
string task_id = 1;
|
||
string task_type = 2;
|
||
string category = 3;
|
||
string metric_type = 4;
|
||
string title = 5;
|
||
string description = 6;
|
||
int64 target_value = 7;
|
||
string target_unit = 8;
|
||
int64 reward_coin_amount = 9;
|
||
string status = 10;
|
||
int32 sort_order = 11;
|
||
int64 version = 12;
|
||
int64 effective_from_ms = 13;
|
||
int64 effective_to_ms = 14;
|
||
int64 created_by_admin_id = 15;
|
||
int64 updated_by_admin_id = 16;
|
||
int64 created_at_ms = 17;
|
||
int64 updated_at_ms = 18;
|
||
}
|
||
|
||
// ListTaskDefinitionsRequest 是后台任务配置列表筛选条件。
|
||
message ListTaskDefinitionsRequest {
|
||
RequestMeta meta = 1;
|
||
string task_type = 2;
|
||
string category = 3;
|
||
string status = 4;
|
||
string keyword = 5;
|
||
int32 page = 6;
|
||
int32 page_size = 7;
|
||
}
|
||
|
||
message ListTaskDefinitionsResponse {
|
||
repeated TaskDefinition tasks = 1;
|
||
int64 total = 2;
|
||
}
|
||
|
||
// UpsertTaskDefinitionRequest 创建或编辑任务;active 关键字段变更由服务端生成新版本。
|
||
message UpsertTaskDefinitionRequest {
|
||
RequestMeta meta = 1;
|
||
string task_id = 2;
|
||
string task_type = 3;
|
||
string category = 4;
|
||
string metric_type = 5;
|
||
string title = 6;
|
||
string description = 7;
|
||
int64 target_value = 8;
|
||
string target_unit = 9;
|
||
int64 reward_coin_amount = 10;
|
||
string status = 11;
|
||
int32 sort_order = 12;
|
||
int64 effective_from_ms = 13;
|
||
int64 effective_to_ms = 14;
|
||
int64 operator_admin_id = 15;
|
||
}
|
||
|
||
message UpsertTaskDefinitionResponse {
|
||
TaskDefinition task = 1;
|
||
bool created = 2;
|
||
}
|
||
|
||
// SetTaskDefinitionStatusRequest 后台启停或归档任务,不做物理删除。
|
||
message SetTaskDefinitionStatusRequest {
|
||
RequestMeta meta = 1;
|
||
string task_id = 2;
|
||
string status = 3;
|
||
int64 operator_admin_id = 4;
|
||
}
|
||
|
||
message SetTaskDefinitionStatusResponse {
|
||
TaskDefinition task = 1;
|
||
}
|
||
|
||
// RegistrationRewardConfig 是注册奖励的当前配置;enabled=false 时保留配置但不自动发放。
|
||
message RegistrationRewardConfig {
|
||
string app_code = 1;
|
||
bool enabled = 2;
|
||
string reward_type = 3;
|
||
int64 coin_amount = 4;
|
||
int64 resource_group_id = 5;
|
||
int64 daily_limit = 6;
|
||
int64 updated_by_admin_id = 7;
|
||
int64 created_at_ms = 8;
|
||
int64 updated_at_ms = 9;
|
||
}
|
||
|
||
// RegistrationRewardClaim 是每个用户注册奖励的领取事实;user_id 唯一保证“没有领过”。
|
||
message RegistrationRewardClaim {
|
||
string claim_id = 1;
|
||
string command_id = 2;
|
||
int64 user_id = 3;
|
||
string reward_day = 4;
|
||
string reward_type = 5;
|
||
int64 coin_amount = 6;
|
||
int64 resource_group_id = 7;
|
||
string status = 8;
|
||
string wallet_command_id = 9;
|
||
string wallet_transaction_id = 10;
|
||
string resource_grant_id = 11;
|
||
string failure_reason = 12;
|
||
int64 claimed_at_ms = 13;
|
||
int64 created_at_ms = 14;
|
||
int64 updated_at_ms = 15;
|
||
}
|
||
|
||
// RegistrationRewardEligibility 返回 App 可直接展示的资格判断;每日份数按 UTC reward_day 统计。
|
||
message RegistrationRewardEligibility {
|
||
bool can_receive = 1;
|
||
string reason = 2;
|
||
bool enabled = 3;
|
||
string reward_type = 4;
|
||
int64 coin_amount = 5;
|
||
int64 resource_group_id = 6;
|
||
int64 daily_limit = 7;
|
||
int64 daily_used = 8;
|
||
int64 daily_remaining = 9;
|
||
string reward_day = 10;
|
||
int64 server_time_ms = 11;
|
||
}
|
||
|
||
// GetRegistrationRewardEligibilityRequest 给 App 查询当前用户是否还有注册奖励资格。
|
||
message GetRegistrationRewardEligibilityRequest {
|
||
RequestMeta meta = 1;
|
||
int64 user_id = 2;
|
||
}
|
||
|
||
message GetRegistrationRewardEligibilityResponse {
|
||
RegistrationRewardEligibility eligibility = 1;
|
||
}
|
||
|
||
// IssueRegistrationRewardRequest 是 user-service 注册成功后调用的幂等发放命令。
|
||
message IssueRegistrationRewardRequest {
|
||
RequestMeta meta = 1;
|
||
int64 user_id = 2;
|
||
string command_id = 3;
|
||
}
|
||
|
||
message IssueRegistrationRewardResponse {
|
||
RegistrationRewardClaim claim = 1;
|
||
RegistrationRewardEligibility eligibility = 2;
|
||
bool issued = 3;
|
||
}
|
||
|
||
// GetRegistrationRewardConfigRequest 返回后台注册奖励配置;未配置时服务端返回默认 disabled 配置。
|
||
message GetRegistrationRewardConfigRequest {
|
||
RequestMeta meta = 1;
|
||
}
|
||
|
||
message GetRegistrationRewardConfigResponse {
|
||
RegistrationRewardConfig config = 1;
|
||
}
|
||
|
||
// UpdateRegistrationRewardConfigRequest 更新注册奖励开关、奖励内容和每日限制。
|
||
message UpdateRegistrationRewardConfigRequest {
|
||
RequestMeta meta = 1;
|
||
bool enabled = 2;
|
||
string reward_type = 3;
|
||
int64 coin_amount = 4;
|
||
int64 resource_group_id = 5;
|
||
int64 daily_limit = 6;
|
||
int64 operator_admin_id = 7;
|
||
}
|
||
|
||
message UpdateRegistrationRewardConfigResponse {
|
||
RegistrationRewardConfig config = 1;
|
||
}
|
||
|
||
// ListRegistrationRewardClaimsRequest 是后台领取记录分页筛选;keyword 由 admin-server 结合用户库扩展。
|
||
message ListRegistrationRewardClaimsRequest {
|
||
RequestMeta meta = 1;
|
||
string status = 2;
|
||
int64 user_id = 3;
|
||
int32 page = 4;
|
||
int32 page_size = 5;
|
||
}
|
||
|
||
message ListRegistrationRewardClaimsResponse {
|
||
repeated RegistrationRewardClaim claims = 1;
|
||
int64 total = 2;
|
||
}
|
||
|
||
// 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);
|
||
}
|
||
|
||
// ActivityCronService 只给 cron-service 调用,活动和消息状态仍由 activity-service owner 修改。
|
||
service ActivityCronService {
|
||
rpc ProcessMessageFanoutBatch(CronBatchRequest) returns (CronBatchResponse);
|
||
}
|
||
|
||
// TaskService 拥有 App 任务查询、事件进度消费和领奖状态。
|
||
service TaskService {
|
||
rpc ListUserTasks(ListUserTasksRequest) returns (ListUserTasksResponse);
|
||
rpc ClaimTaskReward(ClaimTaskRewardRequest) returns (ClaimTaskRewardResponse);
|
||
rpc ConsumeTaskEvent(ConsumeTaskEventRequest) returns (ConsumeTaskEventResponse);
|
||
}
|
||
|
||
// BroadcastService owns server-side Tencent IM global/region broadcast delivery.
|
||
service BroadcastService {
|
||
rpc EnsureBroadcastGroups(EnsureBroadcastGroupsRequest) returns (EnsureBroadcastGroupsResponse);
|
||
rpc PublishRegionBroadcast(PublishRegionBroadcastRequest) returns (PublishBroadcastResponse);
|
||
rpc PublishGlobalBroadcast(PublishGlobalBroadcastRequest) returns (PublishBroadcastResponse);
|
||
rpc RemoveRegionBroadcastMember(RemoveRegionBroadcastMemberRequest) returns (RemoveRegionBroadcastMemberResponse);
|
||
rpc ProcessBroadcastOutboxBatch(CronBatchRequest) returns (ProcessBroadcastOutboxBatchResponse);
|
||
}
|
||
|
||
// RoomEventConsumerService consumes room-service outbox facts without owning Room Cell state.
|
||
service RoomEventConsumerService {
|
||
rpc ConsumeRoomEvent(ConsumeRoomEventRequest) returns (ConsumeRoomEventResponse);
|
||
}
|
||
|
||
// AdminTaskService 是后台活动管理访问 activity-service 的唯一任务配置入口。
|
||
service AdminTaskService {
|
||
rpc ListTaskDefinitions(ListTaskDefinitionsRequest) returns (ListTaskDefinitionsResponse);
|
||
rpc UpsertTaskDefinition(UpsertTaskDefinitionRequest) returns (UpsertTaskDefinitionResponse);
|
||
rpc SetTaskDefinitionStatus(SetTaskDefinitionStatusRequest) returns (SetTaskDefinitionStatusResponse);
|
||
}
|
||
|
||
// RegistrationRewardService 拥有 App 查询和注册完成发放入口。
|
||
service RegistrationRewardService {
|
||
rpc GetRegistrationRewardEligibility(GetRegistrationRewardEligibilityRequest) returns (GetRegistrationRewardEligibilityResponse);
|
||
rpc IssueRegistrationReward(IssueRegistrationRewardRequest) returns (IssueRegistrationRewardResponse);
|
||
}
|
||
|
||
// AdminRegistrationRewardService 是后台活动管理访问注册奖励配置和领取记录的唯一入口。
|
||
service AdminRegistrationRewardService {
|
||
rpc GetRegistrationRewardConfig(GetRegistrationRewardConfigRequest) returns (GetRegistrationRewardConfigResponse);
|
||
rpc UpdateRegistrationRewardConfig(UpdateRegistrationRewardConfigRequest) returns (UpdateRegistrationRewardConfigResponse);
|
||
rpc ListRegistrationRewardClaims(ListRegistrationRewardClaimsRequest) returns (ListRegistrationRewardClaimsResponse);
|
||
}
|