forked from didirus/AstralRinth
Filtering refactoring (#806)
* switching computers * fmt clippy sqlx prepare * merge fixes
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
use crate::auth::checks::{is_visible_project, is_visible_version};
|
||||
use crate::database::models::legacy_loader_fields::MinecraftGameVersion;
|
||||
use crate::database::models::loader_fields::Loader;
|
||||
use crate::database::models::project_item::QueryProject;
|
||||
@@ -7,10 +8,7 @@ use crate::models::pats::Scopes;
|
||||
use crate::models::projects::{ProjectId, VersionId};
|
||||
use crate::queue::session::AuthQueue;
|
||||
use crate::routes::ApiError;
|
||||
use crate::{
|
||||
auth::{get_user_from_headers, is_authorized, is_authorized_version},
|
||||
database,
|
||||
};
|
||||
use crate::{auth::get_user_from_headers, database};
|
||||
use actix_web::{get, route, web, HttpRequest, HttpResponse};
|
||||
use sqlx::PgPool;
|
||||
use std::collections::HashSet;
|
||||
@@ -94,7 +92,7 @@ pub async fn maven_metadata(
|
||||
.map(|x| x.1)
|
||||
.ok();
|
||||
|
||||
if !is_authorized(&project.inner, &user_option, &pool).await? {
|
||||
if !is_visible_project(&project.inner, &user_option, &pool).await? {
|
||||
return Err(ApiError::NotFound);
|
||||
}
|
||||
|
||||
@@ -288,7 +286,7 @@ pub async fn version_file(
|
||||
.map(|x| x.1)
|
||||
.ok();
|
||||
|
||||
if !is_authorized(&project.inner, &user_option, &pool).await? {
|
||||
if !is_visible_project(&project.inner, &user_option, &pool).await? {
|
||||
return Err(ApiError::NotFound);
|
||||
}
|
||||
|
||||
@@ -296,7 +294,7 @@ pub async fn version_file(
|
||||
return Err(ApiError::NotFound);
|
||||
};
|
||||
|
||||
if !is_authorized_version(&version.inner, &user_option, &pool).await? {
|
||||
if !is_visible_version(&version.inner, &user_option, &pool, &redis).await? {
|
||||
return Err(ApiError::NotFound);
|
||||
}
|
||||
|
||||
@@ -349,7 +347,7 @@ pub async fn version_file_sha1(
|
||||
.map(|x| x.1)
|
||||
.ok();
|
||||
|
||||
if !is_authorized(&project.inner, &user_option, &pool).await? {
|
||||
if !is_visible_project(&project.inner, &user_option, &pool).await? {
|
||||
return Err(ApiError::NotFound);
|
||||
}
|
||||
|
||||
@@ -357,7 +355,7 @@ pub async fn version_file_sha1(
|
||||
return Err(ApiError::NotFound);
|
||||
};
|
||||
|
||||
if !is_authorized_version(&version.inner, &user_option, &pool).await? {
|
||||
if !is_visible_version(&version.inner, &user_option, &pool, &redis).await? {
|
||||
return Err(ApiError::NotFound);
|
||||
}
|
||||
|
||||
@@ -391,7 +389,7 @@ pub async fn version_file_sha512(
|
||||
.map(|x| x.1)
|
||||
.ok();
|
||||
|
||||
if !is_authorized(&project.inner, &user_option, &pool).await? {
|
||||
if !is_visible_project(&project.inner, &user_option, &pool).await? {
|
||||
return Err(ApiError::NotFound);
|
||||
}
|
||||
|
||||
@@ -399,7 +397,7 @@ pub async fn version_file_sha512(
|
||||
return Err(ApiError::NotFound);
|
||||
};
|
||||
|
||||
if !is_authorized_version(&version.inner, &user_option, &pool).await? {
|
||||
if !is_visible_version(&version.inner, &user_option, &pool, &redis).await? {
|
||||
return Err(ApiError::NotFound);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user