diff --git a/.env b/.env index e2189242b..f8e9b9270 100644 --- a/.env +++ b/.env @@ -42,4 +42,7 @@ RATE_LIMIT_IGNORE_IPS='["127.0.0.1"]' WHITELISTED_MODPACK_DOMAINS='["cdn.modrinth.com", "edge.forgecdn.net", "github.com", "raw.githubusercontent.com"]' -ALLOWED_CALLBACK_URLS='["localhost", ".modrinth.com", "-modrinth.vercel.app"]' \ No newline at end of file +ALLOWED_CALLBACK_URLS='["localhost", ".modrinth.com", "-modrinth.vercel.app"]' + +ARIADNE_ADMIN_KEY=feedbeef +ARIADNE_URL=https://staging-ariadne.modrinth.com/v1/ \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index d666c684f..c806727fa 100644 --- a/src/main.rs +++ b/src/main.rs @@ -343,5 +343,8 @@ fn check_env_vars() -> bool { failed |= check_var::("GITHUB_CLIENT_ID"); failed |= check_var::("GITHUB_CLIENT_SECRET"); + failed |= check_var::("ARIADNE_ADMIN_KEY"); + failed |= check_var::("ARIADNE_URL"); + failed } diff --git a/src/routes/admin.rs b/src/routes/admin.rs index e6f32178f..54fbe7aca 100644 --- a/src/routes/admin.rs +++ b/src/routes/admin.rs @@ -4,6 +4,7 @@ use crate::util::guards::admin_key_guard; use crate::DownloadQueue; use actix_web::{patch, web, HttpResponse}; use serde::Deserialize; +use serde_json::json; use sqlx::PgPool; use std::sync::Arc; @@ -59,5 +60,18 @@ pub async fn count_download( ) .await; + let client = reqwest::Client::new(); + + client + .post(format!("{}downloads", dotenv::var("ARIADNE_URL")?)) + .header("Modrinth-Admin", dotenv::var("ARIADNE_ADMIN_KEY")?) + .json(&json!({ + "url": download_body.url, + "project_id": download_body.hash + })) + .send() + .await + .ok(); + Ok(HttpResponse::Ok().body("")) }