collab: Only create a Zed Free subscription if there is no other active subscription (#31023)

This PR makes it so we only create a Zed Free subscription if there is
no other active subscription, rather than just having another Zed Free
subscription.

Release Notes:

- N/A

Co-authored-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
This commit is contained in:
Marshall Bowers 2025-05-20 11:00:10 -04:00 committed by GitHub
parent b7d5e6480a
commit 110195cdae
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -320,19 +320,15 @@ impl StripeBilling {
)
.await?;
let existing_zed_free_subscription =
let existing_active_subscription =
existing_subscriptions
.data
.into_iter()
.find(|subscription| {
subscription.status == SubscriptionStatus::Active
&& subscription.items.data.iter().any(|item| {
item.price
.as_ref()
.map_or(false, |price| price.id == zed_free_price_id)
})
|| subscription.status == SubscriptionStatus::Trialing
});
if let Some(subscription) = existing_zed_free_subscription {
if let Some(subscription) = existing_active_subscription {
return Ok(subscription);
}