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?;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue