You've already forked AstralRinth
Fix auth params, Add params to indexing, Order version game versions, Remove version moderation, Return donation platforms in get routes
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
use super::ApiError;
|
||||
use crate::auth::check_is_moderator_from_headers;
|
||||
use crate::database;
|
||||
use crate::models;
|
||||
use crate::models::mods::{ModId, ModStatus, VersionType};
|
||||
use crate::models::mods::{ModId, ModStatus};
|
||||
use crate::models::teams::TeamId;
|
||||
use actix_web::{get, web, HttpRequest, HttpResponse};
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -103,50 +102,3 @@ pub async fn mods(
|
||||
|
||||
Ok(HttpResponse::Ok().json(mods))
|
||||
}
|
||||
|
||||
/// Returns a list of versions that need to be approved
|
||||
#[get("versions")]
|
||||
pub async fn versions(
|
||||
req: HttpRequest,
|
||||
pool: web::Data<PgPool>,
|
||||
count: web::Query<ResultCount>,
|
||||
) -> Result<HttpResponse, ApiError> {
|
||||
check_is_moderator_from_headers(req.headers(), &**pool).await?;
|
||||
|
||||
use futures::stream::TryStreamExt;
|
||||
|
||||
let versions = sqlx::query!(
|
||||
"
|
||||
SELECT * FROM versions
|
||||
WHERE accepted = FALSE
|
||||
ORDER BY date_published ASC
|
||||
LIMIT $1;
|
||||
",
|
||||
count.count as i64
|
||||
)
|
||||
.fetch_many(&**pool)
|
||||
.try_filter_map(|e| async {
|
||||
Ok(e.right().map(|m| models::mods::Version {
|
||||
id: database::models::ids::VersionId(m.id).into(),
|
||||
mod_id: database::models::ids::ModId(m.mod_id).into(),
|
||||
author_id: database::models::ids::UserId(m.author_id).into(),
|
||||
featured: m.featured,
|
||||
name: m.name,
|
||||
version_number: m.version_number,
|
||||
changelog: m.changelog,
|
||||
changelog_url: m.changelog_url,
|
||||
date_published: m.date_published,
|
||||
downloads: m.downloads as u32,
|
||||
version_type: VersionType::Release,
|
||||
files: vec![],
|
||||
dependencies: vec![],
|
||||
game_versions: vec![],
|
||||
loaders: vec![],
|
||||
}))
|
||||
})
|
||||
.try_collect::<Vec<models::mods::Version>>()
|
||||
.await
|
||||
.map_err(|e| ApiError::DatabaseError(e.into()))?;
|
||||
|
||||
Ok(HttpResponse::Ok().json(versions))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user