collab: Only subscribe to Zed Free if there isn't an existing active subscription (#30967)

This PR adds a sanity check to ensure that we only subscribe the user to
Zed Free if they don't already have an active subscription.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2025-05-19 14:26:54 -04:00 committed by GitHub
parent b93c67438c
commit 05f8001ee9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1183,14 +1183,20 @@ async fn sync_subscription(
if subscription.status == SubscriptionStatus::Canceled
|| subscription.status == SubscriptionStatus::Paused
{
let stripe_customer_id = billing_customer
.stripe_customer_id
.parse::<stripe::CustomerId>()
.context("failed to parse Stripe customer ID from database")?;
stripe_billing
.subscribe_to_zed_free(stripe_customer_id)
let already_has_active_billing_subscription = app
.db
.has_active_billing_subscription(billing_customer.user_id)
.await?;
if !already_has_active_billing_subscription {
let stripe_customer_id = billing_customer
.stripe_customer_id
.parse::<stripe::CustomerId>()
.context("failed to parse Stripe customer ID from database")?;
stripe_billing
.subscribe_to_zed_free(stripe_customer_id)
.await?;
}
}
}