Skip to content

Commit 7e8cead

Browse files
Update servers route (#3032)
1 parent fee8d6c commit 7e8cead

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed
Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/labrinth/src/database/models/user_subscription_item.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ impl UserSubscriptionItem {
115115
INNER JOIN products_prices pp ON us.price_id = pp.id
116116
INNER JOIN products p ON p.metadata @> '{"type": "pyro"}'
117117
WHERE $1::text IS NULL OR us.status = $1::text
118+
GROUP BY us.id
118119
"#,
119120
status
120121
)

apps/labrinth/src/routes/internal/billing.rs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -898,14 +898,25 @@ pub async fn active_servers(
898898
)
899899
.await?;
900900

901+
#[derive(Serialize)]
902+
struct ActiveServer {
903+
pub user_id: crate::models::ids::UserId,
904+
pub server_id: String,
905+
pub interval: PriceDuration,
906+
}
907+
901908
let server_ids = servers
902909
.into_iter()
903910
.filter_map(|x| {
904-
x.metadata.map(|x| match x {
905-
SubscriptionMetadata::Pyro { id } => id,
911+
x.metadata.as_ref().map(|metadata| match metadata {
912+
SubscriptionMetadata::Pyro { id } => ActiveServer {
913+
user_id: x.user_id.into(),
914+
server_id: id.clone(),
915+
interval: x.interval,
916+
},
906917
})
907918
})
908-
.collect::<Vec<_>>();
919+
.collect::<Vec<ActiveServer>>();
909920

910921
Ok(HttpResponse::Ok().json(server_ids))
911922
}
@@ -1747,7 +1758,7 @@ pub async fn stripe_webhook(
17471758
"source": source,
17481759
"payment_interval": metadata.charge_item.subscription_interval.map(|x| match x {
17491760
PriceDuration::Monthly => 1,
1750-
PriceDuration::Yearly => 3,
1761+
PriceDuration::Yearly => 12,
17511762
})
17521763
}))
17531764
.send()

0 commit comments

Comments
 (0)