You've already forked AstralRinth
forked from didirus/AstralRinth
Include region in user subscription metadata (#3733)
This commit is contained in:
committed by
GitHub
parent
7b535a1c2a
commit
7223c2b197
@@ -145,7 +145,7 @@ impl SubscriptionStatus {
|
|||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize)]
|
||||||
#[serde(tag = "type", rename_all = "kebab-case")]
|
#[serde(tag = "type", rename_all = "kebab-case")]
|
||||||
pub enum SubscriptionMetadata {
|
pub enum SubscriptionMetadata {
|
||||||
Pyro { id: String },
|
Pyro { id: String, region: Option<String> },
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize)]
|
||||||
|
|||||||
@@ -954,17 +954,19 @@ pub async fn active_servers(
|
|||||||
pub server_id: String,
|
pub server_id: String,
|
||||||
pub price_id: crate::models::ids::ProductPriceId,
|
pub price_id: crate::models::ids::ProductPriceId,
|
||||||
pub interval: PriceDuration,
|
pub interval: PriceDuration,
|
||||||
|
pub region: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
let server_ids = servers
|
let server_ids = servers
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter_map(|x| {
|
.filter_map(|x| {
|
||||||
x.metadata.as_ref().map(|metadata| match metadata {
|
x.metadata.as_ref().map(|metadata| match metadata {
|
||||||
SubscriptionMetadata::Pyro { id } => ActiveServer {
|
SubscriptionMetadata::Pyro { id, region } => ActiveServer {
|
||||||
user_id: x.user_id.into(),
|
user_id: x.user_id.into(),
|
||||||
server_id: id.clone(),
|
server_id: id.clone(),
|
||||||
price_id: x.price_id.into(),
|
price_id: x.price_id.into(),
|
||||||
interval: x.interval,
|
interval: x.interval,
|
||||||
|
region: region.clone(),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -1764,8 +1766,10 @@ pub async fn stripe_webhook(
|
|||||||
{
|
{
|
||||||
let client = reqwest::Client::new();
|
let client = reqwest::Client::new();
|
||||||
|
|
||||||
if let Some(SubscriptionMetadata::Pyro { id }) =
|
if let Some(SubscriptionMetadata::Pyro {
|
||||||
&subscription.metadata
|
id,
|
||||||
|
region: _,
|
||||||
|
}) = &subscription.metadata
|
||||||
{
|
{
|
||||||
client
|
client
|
||||||
.post(format!(
|
.post(format!(
|
||||||
@@ -1880,6 +1884,7 @@ pub async fn stripe_webhook(
|
|||||||
subscription.metadata =
|
subscription.metadata =
|
||||||
Some(SubscriptionMetadata::Pyro {
|
Some(SubscriptionMetadata::Pyro {
|
||||||
id: res.uuid,
|
id: res.uuid,
|
||||||
|
region: server_region,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2240,7 +2245,7 @@ pub async fn index_subscriptions(pool: PgPool, redis: RedisPool) {
|
|||||||
true
|
true
|
||||||
}
|
}
|
||||||
ProductMetadata::Pyro { .. } => {
|
ProductMetadata::Pyro { .. } => {
|
||||||
if let Some(SubscriptionMetadata::Pyro { id }) =
|
if let Some(SubscriptionMetadata::Pyro { id, region: _ }) =
|
||||||
&subscription.metadata
|
&subscription.metadata
|
||||||
{
|
{
|
||||||
let res = reqwest::Client::new()
|
let res = reqwest::Client::new()
|
||||||
|
|||||||
Reference in New Issue
Block a user