feat: added subscription plan cancellation information

This commit is contained in:
Zack Fu Zi Xiang 2024-06-05 12:25:09 +08:00
parent f11f407564
commit 054dc771d4
No known key found for this signature in database
6 changed files with 18 additions and 8 deletions

View File

@ -197,7 +197,7 @@ dependencies = [
[[package]]
name = "appflowy-cloud-billing-client"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud-Billing-Client?rev=5a9b151bbb22e9789867b3ca810f7b35f0f7ebb4#5a9b151bbb22e9789867b3ca810f7b35f0f7ebb4"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud-Billing-Client?rev=48ab2cc33302caf3bb158636817a4010b1fa711e#48ab2cc33302caf3bb158636817a4010b1fa711e"
dependencies = [
"client-api",
"reqwest",

View File

@ -94,7 +94,7 @@ yrs = "0.18.8"
# scripts/tool/update_client_api_rev.sh new_rev_id
# ⚠️⚠️⚠️️
client-api = { version = "0.2" }
appflowy-cloud-billing-client = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud-Billing-Client", rev = "5a9b151bbb22e9789867b3ca810f7b35f0f7ebb4" }
appflowy-cloud-billing-client = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud-Billing-Client", rev = "48ab2cc33302caf3bb158636817a4010b1fa711e" }
[profile.dev]
opt-level = 1

View File

@ -686,5 +686,6 @@ fn to_workspace_subscription(s: WorkspaceSubscriptionStatus) -> WorkspaceSubscri
s.subscription_status,
appflowy_cloud_billing_client::entities::SubscriptionStatus::Active
),
canceled_at: s.canceled_at,
}
}

View File

@ -68,10 +68,10 @@ diesel::table! {
}
diesel::allow_tables_to_appear_in_same_query!(
chat_message_table,
chat_table,
collab_snapshot,
user_data_migration_records,
user_table,
user_workspace_table,
chat_message_table,
chat_table,
collab_snapshot,
user_data_migration_records,
user_table,
user_workspace_table,
);

View File

@ -439,6 +439,7 @@ pub struct WorkspaceSubscription {
pub subscription_plan: SubscriptionPlan,
pub recurring_interval: RecurringInterval,
pub is_active: bool,
pub canceled_at: Option<i64>,
}
pub struct WorkspaceUsage {

View File

@ -299,6 +299,12 @@ pub struct WorkspaceSubscriptionPB {
#[pb(index = 4)]
pub is_active: bool,
#[pb(index = 5)]
pub has_canceled: bool,
#[pb(index = 6)]
pub canceled_at: i64, // value is valid only if has_canceled is true
}
impl From<WorkspaceSubscription> for WorkspaceSubscriptionPB {
@ -308,6 +314,8 @@ impl From<WorkspaceSubscription> for WorkspaceSubscriptionPB {
subscription_plan: s.subscription_plan.into(),
recurring_interval: s.recurring_interval.into(),
is_active: s.is_active,
has_canceled: s.canceled_at.is_some(),
canceled_at: s.canceled_at.unwrap_or_default(),
}
}
}