You've already forked AstralRinth
forked from didirus/AstralRinth
Download counting (#388)
This commit is contained in:
5
.env
5
.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"]'
|
WHITELISTED_MODPACK_DOMAINS='["cdn.modrinth.com", "edge.forgecdn.net", "github.com", "raw.githubusercontent.com"]'
|
||||||
|
|
||||||
ALLOWED_CALLBACK_URLS='["localhost", ".modrinth.com", "-modrinth.vercel.app"]'
|
ALLOWED_CALLBACK_URLS='["localhost", ".modrinth.com", "-modrinth.vercel.app"]'
|
||||||
|
|
||||||
|
ARIADNE_ADMIN_KEY=feedbeef
|
||||||
|
ARIADNE_URL=https://staging-ariadne.modrinth.com/v1/
|
||||||
@@ -343,5 +343,8 @@ fn check_env_vars() -> bool {
|
|||||||
failed |= check_var::<String>("GITHUB_CLIENT_ID");
|
failed |= check_var::<String>("GITHUB_CLIENT_ID");
|
||||||
failed |= check_var::<String>("GITHUB_CLIENT_SECRET");
|
failed |= check_var::<String>("GITHUB_CLIENT_SECRET");
|
||||||
|
|
||||||
|
failed |= check_var::<String>("ARIADNE_ADMIN_KEY");
|
||||||
|
failed |= check_var::<String>("ARIADNE_URL");
|
||||||
|
|
||||||
failed
|
failed
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ use crate::util::guards::admin_key_guard;
|
|||||||
use crate::DownloadQueue;
|
use crate::DownloadQueue;
|
||||||
use actix_web::{patch, web, HttpResponse};
|
use actix_web::{patch, web, HttpResponse};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
use serde_json::json;
|
||||||
use sqlx::PgPool;
|
use sqlx::PgPool;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
@@ -59,5 +60,18 @@ pub async fn count_download(
|
|||||||
)
|
)
|
||||||
.await;
|
.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(""))
|
Ok(HttpResponse::Ok().body(""))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user