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:
parent
b7d5e6480a
commit
110195cdae
1 changed files with 3 additions and 7 deletions
|
@ -320,19 +320,15 @@ impl StripeBilling {
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
let existing_zed_free_subscription =
|
let existing_active_subscription =
|
||||||
existing_subscriptions
|
existing_subscriptions
|
||||||
.data
|
.data
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.find(|subscription| {
|
.find(|subscription| {
|
||||||
subscription.status == SubscriptionStatus::Active
|
subscription.status == SubscriptionStatus::Active
|
||||||
&& subscription.items.data.iter().any(|item| {
|
|| subscription.status == SubscriptionStatus::Trialing
|
||||||
item.price
|
|
||||||
.as_ref()
|
|
||||||
.map_or(false, |price| price.id == zed_free_price_id)
|
|
||||||
})
|
|
||||||
});
|
});
|
||||||
if let Some(subscription) = existing_zed_free_subscription {
|
if let Some(subscription) = existing_active_subscription {
|
||||||
return Ok(subscription);
|
return Ok(subscription);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue