feat: Add player_configs feature and migrate user preferences
- Implemented player_configs table to store multiple player configurations per user. - Migrated existing player settings from user_preferences to player_configs. - Removed player-related columns from user_preferences. - Added referral state fields to user for tracking referral rewards. - Created migration scripts for database changes and data migration. - Added test cases for app services and usage helpers. - Introduced video job service interfaces and implementations.
This commit is contained in:
@@ -3,7 +3,7 @@ syntax = "proto3";
|
||||
package stream.app.v1;
|
||||
|
||||
option go_package = "stream.api/internal/gen/proto/app/v1;appv1";
|
||||
|
||||
import "google/protobuf/wrappers.proto";
|
||||
import "app/v1/common.proto";
|
||||
|
||||
service AccountService {
|
||||
@@ -11,6 +11,7 @@ service AccountService {
|
||||
rpc UpdateMe(UpdateMeRequest) returns (UpdateMeResponse);
|
||||
rpc DeleteMe(DeleteMeRequest) returns (MessageResponse);
|
||||
rpc ClearMyData(ClearMyDataRequest) returns (MessageResponse);
|
||||
rpc GetUserById (google.protobuf.StringValue) returns (User) {}
|
||||
}
|
||||
|
||||
service PreferencesService {
|
||||
@@ -41,6 +42,7 @@ message UpdateMeRequest {
|
||||
optional string email = 2;
|
||||
optional string language = 3;
|
||||
optional string locale = 4;
|
||||
optional string telegram_id = 5;
|
||||
}
|
||||
|
||||
message UpdateMeResponse {
|
||||
|
||||
@@ -12,6 +12,7 @@ service AdminService {
|
||||
rpc GetAdminUser(GetAdminUserRequest) returns (GetAdminUserResponse);
|
||||
rpc CreateAdminUser(CreateAdminUserRequest) returns (CreateAdminUserResponse);
|
||||
rpc UpdateAdminUser(UpdateAdminUserRequest) returns (UpdateAdminUserResponse);
|
||||
rpc UpdateAdminUserReferralSettings(UpdateAdminUserReferralSettingsRequest) returns (UpdateAdminUserReferralSettingsResponse);
|
||||
rpc UpdateAdminUserRole(UpdateAdminUserRoleRequest) returns (UpdateAdminUserRoleResponse);
|
||||
rpc DeleteAdminUser(DeleteAdminUserRequest) returns (MessageResponse);
|
||||
rpc ListAdminVideos(ListAdminVideosRequest) returns (ListAdminVideosResponse);
|
||||
@@ -32,6 +33,11 @@ service AdminService {
|
||||
rpc CreateAdminAdTemplate(CreateAdminAdTemplateRequest) returns (CreateAdminAdTemplateResponse);
|
||||
rpc UpdateAdminAdTemplate(UpdateAdminAdTemplateRequest) returns (UpdateAdminAdTemplateResponse);
|
||||
rpc DeleteAdminAdTemplate(DeleteAdminAdTemplateRequest) returns (MessageResponse);
|
||||
rpc ListAdminPlayerConfigs(ListAdminPlayerConfigsRequest) returns (ListAdminPlayerConfigsResponse);
|
||||
rpc GetAdminPlayerConfig(GetAdminPlayerConfigRequest) returns (GetAdminPlayerConfigResponse);
|
||||
rpc CreateAdminPlayerConfig(CreateAdminPlayerConfigRequest) returns (CreateAdminPlayerConfigResponse);
|
||||
rpc UpdateAdminPlayerConfig(UpdateAdminPlayerConfigRequest) returns (UpdateAdminPlayerConfigResponse);
|
||||
rpc DeleteAdminPlayerConfig(DeleteAdminPlayerConfigRequest) returns (MessageResponse);
|
||||
rpc ListAdminJobs(ListAdminJobsRequest) returns (ListAdminJobsResponse);
|
||||
rpc GetAdminJob(GetAdminJobRequest) returns (GetAdminJobResponse);
|
||||
rpc GetAdminJobLogs(GetAdminJobLogsRequest) returns (GetAdminJobLogsResponse);
|
||||
@@ -96,6 +102,19 @@ message UpdateAdminUserResponse {
|
||||
AdminUser user = 1;
|
||||
}
|
||||
|
||||
message UpdateAdminUserReferralSettingsRequest {
|
||||
string id = 1;
|
||||
optional string ref_username = 2;
|
||||
optional bool clear_referrer = 3;
|
||||
optional bool referral_eligible = 4;
|
||||
optional int32 referral_reward_bps = 5;
|
||||
optional bool clear_referral_reward_bps = 6;
|
||||
}
|
||||
|
||||
message UpdateAdminUserReferralSettingsResponse {
|
||||
AdminUserDetail user = 1;
|
||||
}
|
||||
|
||||
message UpdateAdminUserRoleRequest {
|
||||
string id = 1;
|
||||
string role = 2;
|
||||
@@ -319,8 +338,81 @@ message DeleteAdminAdTemplateRequest {
|
||||
string id = 1;
|
||||
}
|
||||
|
||||
message ListAdminPlayerConfigsRequest {
|
||||
int32 page = 1;
|
||||
int32 limit = 2;
|
||||
optional string user_id = 3;
|
||||
optional string search = 4;
|
||||
}
|
||||
|
||||
message ListAdminPlayerConfigsResponse {
|
||||
repeated AdminPlayerConfig configs = 1;
|
||||
int64 total = 2;
|
||||
int32 page = 3;
|
||||
int32 limit = 4;
|
||||
}
|
||||
|
||||
message GetAdminPlayerConfigRequest {
|
||||
string id = 1;
|
||||
}
|
||||
|
||||
message GetAdminPlayerConfigResponse {
|
||||
AdminPlayerConfig config = 1;
|
||||
}
|
||||
|
||||
message CreateAdminPlayerConfigRequest {
|
||||
string user_id = 1;
|
||||
string name = 2;
|
||||
optional string description = 3;
|
||||
bool autoplay = 4;
|
||||
bool loop = 5;
|
||||
bool muted = 6;
|
||||
bool show_controls = 7;
|
||||
bool pip = 8;
|
||||
bool airplay = 9;
|
||||
bool chromecast = 10;
|
||||
optional bool is_active = 11;
|
||||
optional bool is_default = 12;
|
||||
optional bool encrytion_m3u8 = 13;
|
||||
optional string logo_url = 14;
|
||||
}
|
||||
|
||||
message CreateAdminPlayerConfigResponse {
|
||||
AdminPlayerConfig config = 1;
|
||||
}
|
||||
|
||||
message UpdateAdminPlayerConfigRequest {
|
||||
string id = 1;
|
||||
string user_id = 2;
|
||||
string name = 3;
|
||||
optional string description = 4;
|
||||
bool autoplay = 5;
|
||||
bool loop = 6;
|
||||
bool muted = 7;
|
||||
bool show_controls = 8;
|
||||
bool pip = 9;
|
||||
bool airplay = 10;
|
||||
bool chromecast = 11;
|
||||
optional bool is_active = 12;
|
||||
optional bool is_default = 13;
|
||||
optional bool encrytion_m3u8 = 14;
|
||||
optional string logo_url = 15;
|
||||
}
|
||||
|
||||
message UpdateAdminPlayerConfigResponse {
|
||||
AdminPlayerConfig config = 1;
|
||||
}
|
||||
|
||||
message DeleteAdminPlayerConfigRequest {
|
||||
string id = 1;
|
||||
}
|
||||
|
||||
message ListAdminJobsRequest {
|
||||
optional string cursor = 4;
|
||||
int32 page_size = 5;
|
||||
// Deprecated: use cursor for keyset pagination.
|
||||
int32 offset = 1;
|
||||
// Deprecated: use page_size for keyset pagination.
|
||||
int32 limit = 2;
|
||||
optional string agent_id = 3;
|
||||
}
|
||||
@@ -331,6 +423,8 @@ message ListAdminJobsResponse {
|
||||
int32 offset = 3;
|
||||
int32 limit = 4;
|
||||
bool has_more = 5;
|
||||
optional string next_cursor = 6;
|
||||
int32 page_size = 7;
|
||||
}
|
||||
|
||||
message GetAdminJobRequest {
|
||||
@@ -357,6 +451,7 @@ message CreateAdminJobRequest {
|
||||
optional string user_id = 5;
|
||||
optional string name = 6;
|
||||
int64 time_limit = 7;
|
||||
optional string video_id = 8;
|
||||
}
|
||||
|
||||
message CreateAdminJobResponse {
|
||||
|
||||
@@ -30,6 +30,7 @@ message RegisterRequest {
|
||||
string username = 1;
|
||||
string email = 2;
|
||||
string password = 3;
|
||||
optional string ref_username = 4;
|
||||
}
|
||||
|
||||
message RegisterResponse {
|
||||
@@ -60,6 +61,7 @@ message GetGoogleLoginUrlResponse {
|
||||
|
||||
message CompleteGoogleLoginRequest {
|
||||
string code = 1;
|
||||
optional string ref_username = 2;
|
||||
}
|
||||
|
||||
message CompleteGoogleLoginResponse {
|
||||
|
||||
@@ -19,6 +19,13 @@ service AdTemplatesService {
|
||||
rpc DeleteAdTemplate(DeleteAdTemplateRequest) returns (MessageResponse);
|
||||
}
|
||||
|
||||
service PlayerConfigsService {
|
||||
rpc ListPlayerConfigs(ListPlayerConfigsRequest) returns (ListPlayerConfigsResponse);
|
||||
rpc CreatePlayerConfig(CreatePlayerConfigRequest) returns (CreatePlayerConfigResponse);
|
||||
rpc UpdatePlayerConfig(UpdatePlayerConfigRequest) returns (UpdatePlayerConfigResponse);
|
||||
rpc DeletePlayerConfig(DeletePlayerConfigRequest) returns (MessageResponse);
|
||||
}
|
||||
|
||||
service PlansService {
|
||||
rpc ListPlans(ListPlansRequest) returns (ListPlansResponse);
|
||||
}
|
||||
@@ -80,6 +87,57 @@ message DeleteAdTemplateRequest {
|
||||
string id = 1;
|
||||
}
|
||||
|
||||
message ListPlayerConfigsRequest {}
|
||||
|
||||
message ListPlayerConfigsResponse {
|
||||
repeated PlayerConfig configs = 1;
|
||||
}
|
||||
|
||||
message CreatePlayerConfigRequest {
|
||||
string name = 1;
|
||||
optional string description = 2;
|
||||
bool autoplay = 3;
|
||||
bool loop = 4;
|
||||
bool muted = 5;
|
||||
bool show_controls = 6;
|
||||
bool pip = 7;
|
||||
bool airplay = 8;
|
||||
bool chromecast = 9;
|
||||
optional bool is_active = 10;
|
||||
optional bool is_default = 11;
|
||||
optional bool encrytion_m3u8 = 12;
|
||||
optional string logo_url = 13;
|
||||
}
|
||||
|
||||
message CreatePlayerConfigResponse {
|
||||
PlayerConfig config = 1;
|
||||
}
|
||||
|
||||
message UpdatePlayerConfigRequest {
|
||||
string id = 1;
|
||||
string name = 2;
|
||||
optional string description = 3;
|
||||
bool autoplay = 4;
|
||||
bool loop = 5;
|
||||
bool muted = 6;
|
||||
bool show_controls = 7;
|
||||
bool pip = 8;
|
||||
bool airplay = 9;
|
||||
bool chromecast = 10;
|
||||
optional bool is_active = 11;
|
||||
optional bool is_default = 12;
|
||||
optional bool encrytion_m3u8 = 13;
|
||||
optional string logo_url = 14;
|
||||
}
|
||||
|
||||
message UpdatePlayerConfigResponse {
|
||||
PlayerConfig config = 1;
|
||||
}
|
||||
|
||||
message DeletePlayerConfigRequest {
|
||||
string id = 1;
|
||||
}
|
||||
|
||||
message ListPlansRequest {}
|
||||
|
||||
message ListPlansResponse {
|
||||
|
||||
@@ -27,8 +27,9 @@ message User {
|
||||
double wallet_balance = 14;
|
||||
string language = 15;
|
||||
string locale = 16;
|
||||
google.protobuf.Timestamp created_at = 17;
|
||||
google.protobuf.Timestamp updated_at = 18;
|
||||
string telegram_id = 17;
|
||||
google.protobuf.Timestamp created_at = 18;
|
||||
google.protobuf.Timestamp updated_at = 19;
|
||||
}
|
||||
|
||||
message Preferences {
|
||||
@@ -78,6 +79,46 @@ message AdTemplate {
|
||||
google.protobuf.Timestamp updated_at = 10;
|
||||
}
|
||||
|
||||
message PlayerConfig {
|
||||
string id = 1;
|
||||
string name = 2;
|
||||
optional string description = 3;
|
||||
bool autoplay = 4;
|
||||
bool loop = 5;
|
||||
bool muted = 6;
|
||||
bool show_controls = 7;
|
||||
bool pip = 8;
|
||||
bool airplay = 9;
|
||||
bool chromecast = 10;
|
||||
bool is_active = 11;
|
||||
bool is_default = 12;
|
||||
google.protobuf.Timestamp created_at = 13;
|
||||
google.protobuf.Timestamp updated_at = 14;
|
||||
bool encrytion_m3u8 = 15;
|
||||
optional string logo_url = 16;
|
||||
}
|
||||
|
||||
message AdminPlayerConfig {
|
||||
string id = 1;
|
||||
string user_id = 2;
|
||||
string name = 3;
|
||||
optional string description = 4;
|
||||
bool autoplay = 5;
|
||||
bool loop = 6;
|
||||
bool muted = 7;
|
||||
bool show_controls = 8;
|
||||
bool pip = 9;
|
||||
bool airplay = 10;
|
||||
bool chromecast = 11;
|
||||
bool is_active = 12;
|
||||
bool is_default = 13;
|
||||
optional string owner_email = 14;
|
||||
google.protobuf.Timestamp created_at = 15;
|
||||
google.protobuf.Timestamp updated_at = 16;
|
||||
bool encrytion_m3u8 = 17;
|
||||
optional string logo_url = 18;
|
||||
}
|
||||
|
||||
message Plan {
|
||||
string id = 1;
|
||||
string name = 2;
|
||||
@@ -164,6 +205,7 @@ message Video {
|
||||
optional string storage_type = 12;
|
||||
google.protobuf.Timestamp created_at = 13;
|
||||
google.protobuf.Timestamp updated_at = 14;
|
||||
optional string job_id = 15;
|
||||
}
|
||||
|
||||
message AdminDashboard {
|
||||
@@ -193,9 +235,28 @@ message AdminUser {
|
||||
google.protobuf.Timestamp updated_at = 12;
|
||||
}
|
||||
|
||||
message ReferralUserSummary {
|
||||
string id = 1;
|
||||
string email = 2;
|
||||
optional string username = 3;
|
||||
}
|
||||
|
||||
message AdminUserReferralInfo {
|
||||
optional ReferralUserSummary referrer = 1;
|
||||
bool referral_eligible = 2;
|
||||
double effective_reward_percent = 3;
|
||||
optional double reward_override_percent = 4;
|
||||
optional string share_link = 5;
|
||||
bool reward_granted = 6;
|
||||
google.protobuf.Timestamp reward_granted_at = 7;
|
||||
optional string reward_payment_id = 8;
|
||||
optional double reward_amount = 9;
|
||||
}
|
||||
|
||||
message AdminUserDetail {
|
||||
AdminUser user = 1;
|
||||
optional PlanSubscription subscription = 2;
|
||||
optional AdminUserReferralInfo referral = 3;
|
||||
}
|
||||
|
||||
message AdminVideo {
|
||||
@@ -213,6 +274,8 @@ message AdminVideo {
|
||||
optional string ad_template_name = 12;
|
||||
google.protobuf.Timestamp created_at = 13;
|
||||
google.protobuf.Timestamp updated_at = 14;
|
||||
optional string processing_status = 15;
|
||||
optional string job_id = 16;
|
||||
}
|
||||
|
||||
message AdminPayment {
|
||||
@@ -288,6 +351,7 @@ message AdminJob {
|
||||
int32 max_retries = 17;
|
||||
google.protobuf.Timestamp created_at = 18;
|
||||
google.protobuf.Timestamp updated_at = 19;
|
||||
optional string video_id = 20;
|
||||
}
|
||||
|
||||
message AdminAgent {
|
||||
|
||||
@@ -28,10 +28,18 @@ message CreatePaymentResponse {
|
||||
string message = 5;
|
||||
}
|
||||
|
||||
message ListPaymentHistoryRequest {}
|
||||
message ListPaymentHistoryRequest {
|
||||
int32 page = 1;
|
||||
int32 limit = 2;
|
||||
}
|
||||
|
||||
message ListPaymentHistoryResponse {
|
||||
repeated PaymentHistoryItem payments = 1;
|
||||
int64 total = 2;
|
||||
int32 page = 3;
|
||||
int32 limit = 4;
|
||||
bool has_prev = 5;
|
||||
bool has_next = 6;
|
||||
}
|
||||
|
||||
message TopupWalletRequest {
|
||||
|
||||
Reference in New Issue
Block a user