diff --git a/apps/labrinth/.env b/apps/labrinth/.env index 3a73d505..1a335918 100644 --- a/apps/labrinth/.env +++ b/apps/labrinth/.env @@ -116,4 +116,6 @@ BREX_API_URL=https://platform.brexapis.com/v2/ BREX_API_KEY=none DELPHI_URL=none -DELPHI_SLACK_WEBHOOK=none \ No newline at end of file +DELPHI_SLACK_WEBHOOK=none + +ARCHON_URL=none \ No newline at end of file diff --git a/apps/labrinth/src/lib.rs b/apps/labrinth/src/lib.rs index 4ad4510d..bfaf95d8 100644 --- a/apps/labrinth/src/lib.rs +++ b/apps/labrinth/src/lib.rs @@ -502,5 +502,7 @@ pub fn check_env_vars() -> bool { failed |= check_var::("DELPHI_URL"); + failed |= check_var::("ARCHON_URL"); + failed } diff --git a/apps/labrinth/src/routes/internal/billing.rs b/apps/labrinth/src/routes/internal/billing.rs index 8488af0d..036c3c3d 100644 --- a/apps/labrinth/src/routes/internal/billing.rs +++ b/apps/labrinth/src/routes/internal/billing.rs @@ -1749,7 +1749,8 @@ pub async fn stripe_webhook( { client .post(format!( - "https://archon.pyro.host/modrinth/v0/servers/{}/unsuspend", + "{}/modrinth/v0/servers/{}/unsuspend", + dotenvy::var("ARCHON_URL")?, id )) .header("X-Master-Key", dotenvy::var("PYRO_API_KEY")?) @@ -1757,20 +1758,25 @@ pub async fn stripe_webhook( .await? .error_for_status()?; - client.post(format!( - "https://archon.pyro.host/modrinth/v0/servers/{}/reallocate", + client + .post(format!( + "{}/modrinth/v0/servers/{}/reallocate", + dotenvy::var("ARCHON_URL")?, id )) - .header("X-Master-Key", dotenvy::var("PYRO_API_KEY")?) - .json(&serde_json::json!({ - "memory_mb": ram, - "cpu": cpu, - "swap_mb": swap, - "storage_mb": storage, - })) - .send() - .await? - .error_for_status()?; + .header( + "X-Master-Key", + dotenvy::var("PYRO_API_KEY")?, + ) + .json(&serde_json::json!({ + "memory_mb": ram, + "cpu": cpu, + "swap_mb": swap, + "storage_mb": storage, + })) + .send() + .await? + .error_for_status()?; } else { let (server_name, source) = if let Some( PaymentRequestMetadata::Pyro { @@ -1814,7 +1820,10 @@ pub async fn stripe_webhook( } let res = client - .post("https://archon.pyro.host/modrinth/v0/servers/create") + .post(format!( + "{}/modrinth/v0/servers/create", + dotenvy::var("ARCHON_URL")?, + )) .header("X-Master-Key", dotenvy::var("PYRO_API_KEY")?) .json(&serde_json::json!({ "user_id": to_base62(metadata.user_item.id.0 as u64), @@ -2201,7 +2210,8 @@ pub async fn subscription_task(pool: PgPool, redis: RedisPool) { { let res = reqwest::Client::new() .post(format!( - "https://archon.pyro.host/modrinth/v0/servers/{}/suspend", + "{}/modrinth/v0/servers/{}/suspend", + dotenvy::var("ARCHON_URL")?, id )) .header("X-Master-Key", dotenvy::var("PYRO_API_KEY")?)