You've already forked AstralRinth
forked from didirus/AstralRinth
Technical review queue (#4775)
* chore: fix typo in status message * feat(labrinth): overhaul malware scanner report storage and routes * chore: address some review comments * feat: add Delphi to Docker Compose `with-delphi` profile * chore: fix unused import Clippy lint * feat(labrinth/delphi): use PAT token authorization with project read scopes * chore: expose file IDs in version queries * fix: accept null decompiled source payloads from Delphi * tweak(labrinth): expose base62 file IDs more consistently for Delphi * feat(labrinth/delphi): support new Delphi report severity field * chore(labrinth): run `cargo sqlx prepare` to fix Docker build errors * tweak: add route for fetching Delphi issue type schema, abstract Labrinth away from issue types * chore: run `cargo sqlx prepare` * chore: fix typo on frontend generated state file message * feat: update to use new Delphi issue schema * wip: tech review endpoints * wip: add ToSchema for dependent types * wip: report issues return * wip * wip: returning more data * wip * Fix up db query * Delphi configuration to talk to Labrinth * Get Delphi working with Labrinth * Add Delphi dummy fixture * Better Delphi logging * Improve utoipa for tech review routes * Add more sorting options for tech review queue * Oops join * New routes for fetching issues and reports * Fix which kind of ID is returned in tech review endpoints * Deduplicate tech review report rows * Reduce info sent for projects * Fetch more thread info * Address PR comments * fix ci * fix postgres version mismatch * fix version creation * Implement routes * fix up tech review * Allow adding a moderation comment to Delphi rejections * fix up rebase * exclude rejected projects from tech review * add status change msg to tech review thread * cargo sqlx prepare * also ignore withheld projects * More filtering on issue search * wip: report routes * Fix up for build * cargo sqlx prepare * fix thread message privacy * New tech review search route * submit route * details have statuses now * add default to drid status * dedup issue details * fix sqlx query on empty files * fixes * Dedupe issue detail statuses and message on entering tech rev * Fix qa issues * Fix qa issues * fix review comments * typos * fix ci * feat: tech review frontend (#4781) * chore: fix typo in status message * feat(labrinth): overhaul malware scanner report storage and routes * chore: address some review comments * feat: add Delphi to Docker Compose `with-delphi` profile * chore: fix unused import Clippy lint * feat(labrinth/delphi): use PAT token authorization with project read scopes * chore: expose file IDs in version queries * fix: accept null decompiled source payloads from Delphi * tweak(labrinth): expose base62 file IDs more consistently for Delphi * feat(labrinth/delphi): support new Delphi report severity field * chore(labrinth): run `cargo sqlx prepare` to fix Docker build errors * tweak: add route for fetching Delphi issue type schema, abstract Labrinth away from issue types * chore: run `cargo sqlx prepare` * chore: fix typo on frontend generated state file message * feat: update to use new Delphi issue schema * wip: tech review endpoints * wip: add ToSchema for dependent types * wip: report issues return * wip * wip: returning more data * wip * Fix up db query * Delphi configuration to talk to Labrinth * Get Delphi working with Labrinth * Add Delphi dummy fixture * Better Delphi logging * Improve utoipa for tech review routes * Add more sorting options for tech review queue * Oops join * New routes for fetching issues and reports * Fix which kind of ID is returned in tech review endpoints * Deduplicate tech review report rows * Reduce info sent for projects * Fetch more thread info * Address PR comments * fix ci * fix ci * fix postgres version mismatch * fix version creation * Implement routes * feat: batch scan alert * feat: layout * feat: introduce surface variables * fix: theme selector * feat: rough draft of tech review card * feat: tab switcher * feat: batch scan btn * feat: api-client module for tech review * draft: impl * feat: auto icons * fix: layout issues * feat: fixes to code blocks + flag labels * feat: temp remove mock data * fix: search sort types * fix: intl & lint * chore: re-enable mock data * fix: flag badges + auto open first issue in file tab * feat: update for new routes * fix: more qa issues * feat: lazy load sources * fix: re-enable auth middleware * feat: impl threads * fix: lint & severity * feat: download btn + switch to using NavTabs with new local mode option * feat: re-add toplevel btns * feat: reports page consistency * fix: consistency on project queue * fix: icons + sizing * fix: colors and gaps * fix: impl endpoints * feat: load all flags on file tab * feat: thread generics changes * feat: more qa * feat: fix collapse * fix: qa * feat: msg modal * fix: ISO import * feat: qa fixes * fix: empty state basic * fix: collapsible region * fix: collapse thread by default * feat: rough draft of new process/flow * fix labrinth build * fix thread message privacy * New tech review search route * feat: qa fixes * feat: QA changes * fix: verdict on detail not whole issue * fix: lint + intl * fix: lint * fix: thread message for tech rev verdict * feat: use anim frames * fix: exports + typecheck * polish: qa changes * feat: qa * feat: qa polish * feat: fix malic modal * fix: lint * fix: qa + lint * fix: pagination * fix: lint * fix: qa * intl extract * fix ci --------- Signed-off-by: Calum H. <contact@cal.engineer> Co-authored-by: Alejandro González <me@alegon.dev> Co-authored-by: aecsocket <aecsocket@tutanota.com> --------- Signed-off-by: Calum H. <contact@cal.engineer> Co-authored-by: Alejandro González <me@alegon.dev> Co-authored-by: Calum H. <contact@cal.engineer>
This commit is contained in:
@@ -413,9 +413,6 @@ async fn project_create_inner(
|
||||
session_queue: &AuthQueue,
|
||||
project_id: ProjectId,
|
||||
) -> Result<HttpResponse, CreateError> {
|
||||
// The base URL for files uploaded to S3
|
||||
let cdn_url = dotenvy::var("CDN_URL")?;
|
||||
|
||||
// The currently logged in user
|
||||
let (_, current_user) = get_user_from_headers(
|
||||
&req,
|
||||
@@ -651,7 +648,6 @@ async fn project_create_inner(
|
||||
uploaded_files,
|
||||
&mut created_version.files,
|
||||
&mut created_version.dependencies,
|
||||
&cdn_url,
|
||||
&content_disposition,
|
||||
project_id,
|
||||
created_version.version_id.into(),
|
||||
|
||||
@@ -380,7 +380,25 @@ pub async fn thread_send_message(
|
||||
.await?
|
||||
.1;
|
||||
|
||||
let string: database::models::DBThreadId = info.into_inner().0.into();
|
||||
thread_send_message_internal(
|
||||
&user,
|
||||
info.into_inner().0,
|
||||
&pool,
|
||||
new_message.into_inner(),
|
||||
&redis,
|
||||
)
|
||||
.await?;
|
||||
Ok(HttpResponse::NoContent().finish())
|
||||
}
|
||||
|
||||
pub async fn thread_send_message_internal(
|
||||
user: &User,
|
||||
thread_id: ThreadId,
|
||||
pool: &PgPool,
|
||||
new_message: NewThreadMessage,
|
||||
redis: &RedisPool,
|
||||
) -> Result<(), ApiError> {
|
||||
let string: database::models::DBThreadId = thread_id.into();
|
||||
|
||||
let is_private: bool;
|
||||
|
||||
@@ -406,7 +424,7 @@ pub async fn thread_send_message(
|
||||
if let Some(replying_to) = replying_to {
|
||||
let thread_message = database::models::DBThreadMessage::get(
|
||||
(*replying_to).into(),
|
||||
&**pool,
|
||||
pool,
|
||||
)
|
||||
.await?;
|
||||
|
||||
@@ -431,10 +449,10 @@ pub async fn thread_send_message(
|
||||
));
|
||||
}
|
||||
|
||||
let result = database::models::DBThread::get(string, &**pool).await?;
|
||||
let result = database::models::DBThread::get(string, pool).await?;
|
||||
|
||||
if let Some(thread) = result {
|
||||
if !is_authorized_thread(&thread, &user, &pool).await? {
|
||||
if !is_authorized_thread(&thread, user, pool).await? {
|
||||
return Err(ApiError::NotFound);
|
||||
}
|
||||
|
||||
@@ -450,10 +468,9 @@ pub async fn thread_send_message(
|
||||
.await?;
|
||||
|
||||
if let Some(project_id) = thread.project_id {
|
||||
let project = database::models::DBProject::get_id(
|
||||
project_id, &**pool, &redis,
|
||||
)
|
||||
.await?;
|
||||
let project =
|
||||
database::models::DBProject::get_id(project_id, pool, redis)
|
||||
.await?;
|
||||
|
||||
if let Some(project) = project
|
||||
&& project.inner.status != ProjectStatus::Processing
|
||||
@@ -463,8 +480,8 @@ pub async fn thread_send_message(
|
||||
let members =
|
||||
database::models::DBTeamMember::get_from_team_full(
|
||||
project.inner.team_id,
|
||||
&**pool,
|
||||
&redis,
|
||||
pool,
|
||||
redis,
|
||||
)
|
||||
.await?;
|
||||
|
||||
@@ -479,7 +496,7 @@ pub async fn thread_send_message(
|
||||
.insert_many(
|
||||
members.iter().map(|x| x.user_id).collect(),
|
||||
&mut transaction,
|
||||
&redis,
|
||||
redis,
|
||||
)
|
||||
.await?;
|
||||
|
||||
@@ -491,15 +508,14 @@ pub async fn thread_send_message(
|
||||
.insert_many(
|
||||
members.iter().map(|x| x.user_id).collect(),
|
||||
&mut transaction,
|
||||
&redis,
|
||||
redis,
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
} else if let Some(report_id) = thread.report_id {
|
||||
let report = database::models::report_item::DBReport::get(
|
||||
report_id, &**pool,
|
||||
)
|
||||
.await?;
|
||||
let report =
|
||||
database::models::report_item::DBReport::get(report_id, pool)
|
||||
.await?;
|
||||
|
||||
if let Some(report) = report {
|
||||
if report.closed && !user.role.is_mod() {
|
||||
@@ -517,7 +533,7 @@ pub async fn thread_send_message(
|
||||
report_id: Some(report.id.into()),
|
||||
},
|
||||
}
|
||||
.insert(report.reporter, &mut transaction, &redis)
|
||||
.insert(report.reporter, &mut transaction, redis)
|
||||
.await?;
|
||||
}
|
||||
}
|
||||
@@ -531,7 +547,7 @@ pub async fn thread_send_message(
|
||||
if let Some(db_image) = image_item::DBImage::get(
|
||||
(*image_id).into(),
|
||||
&mut *transaction,
|
||||
&redis,
|
||||
redis,
|
||||
)
|
||||
.await?
|
||||
{
|
||||
@@ -558,7 +574,7 @@ pub async fn thread_send_message(
|
||||
.execute(&mut *transaction)
|
||||
.await?;
|
||||
|
||||
image_item::DBImage::clear_cache(image.id.into(), &redis)
|
||||
image_item::DBImage::clear_cache(image.id.into(), redis)
|
||||
.await?;
|
||||
} else {
|
||||
return Err(ApiError::InvalidInput(format!(
|
||||
@@ -570,7 +586,7 @@ pub async fn thread_send_message(
|
||||
|
||||
transaction.commit().await?;
|
||||
|
||||
Ok(HttpResponse::NoContent().body(""))
|
||||
Ok(())
|
||||
} else {
|
||||
Err(ApiError::NotFound)
|
||||
}
|
||||
@@ -630,14 +646,7 @@ pub async fn message_delete(
|
||||
.await?;
|
||||
}
|
||||
|
||||
let private = if let MessageBody::Text { private, .. } = thread.body {
|
||||
private
|
||||
} else if let MessageBody::Deleted { private, .. } = thread.body {
|
||||
private
|
||||
} else {
|
||||
false
|
||||
};
|
||||
|
||||
let private = thread.body.is_private();
|
||||
database::models::DBThreadMessage::remove_full(
|
||||
thread.id,
|
||||
private,
|
||||
|
||||
@@ -38,7 +38,6 @@ use sha1::Digest;
|
||||
use sqlx::postgres::PgPool;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::sync::Arc;
|
||||
use tracing::error;
|
||||
use validator::Validate;
|
||||
|
||||
fn default_requested_status() -> VersionStatus {
|
||||
@@ -158,8 +157,6 @@ async fn version_create_inner(
|
||||
session_queue: &AuthQueue,
|
||||
moderation_queue: &AutomatedModerationQueue,
|
||||
) -> Result<HttpResponse, CreateError> {
|
||||
let cdn_url = dotenvy::var("CDN_URL")?;
|
||||
|
||||
let mut initial_version_data = None;
|
||||
let mut version_builder = None;
|
||||
let mut selected_loaders = None;
|
||||
@@ -355,7 +352,6 @@ async fn version_create_inner(
|
||||
uploaded_files,
|
||||
&mut version.files,
|
||||
&mut version.dependencies,
|
||||
&cdn_url,
|
||||
&content_disposition,
|
||||
version.project_id.into(),
|
||||
version.version_id.into(),
|
||||
@@ -451,6 +447,7 @@ async fn version_create_inner(
|
||||
.files
|
||||
.iter()
|
||||
.map(|file| VersionFile {
|
||||
id: None,
|
||||
hashes: file
|
||||
.hashes
|
||||
.iter()
|
||||
@@ -590,8 +587,6 @@ async fn upload_file_to_version_inner(
|
||||
version_id: models::DBVersionId,
|
||||
session_queue: &AuthQueue,
|
||||
) -> Result<HttpResponse, CreateError> {
|
||||
let cdn_url = dotenvy::var("CDN_URL")?;
|
||||
|
||||
let mut initial_file_data: Option<InitialFileData> = None;
|
||||
let mut file_builders: Vec<VersionFileBuilder> = Vec::new();
|
||||
|
||||
@@ -741,7 +736,6 @@ async fn upload_file_to_version_inner(
|
||||
uploaded_files,
|
||||
&mut file_builders,
|
||||
&mut dependencies,
|
||||
&cdn_url,
|
||||
&content_disposition,
|
||||
project_id,
|
||||
version_id.into(),
|
||||
@@ -795,7 +789,6 @@ pub async fn upload_file(
|
||||
uploaded_files: &mut Vec<UploadedFile>,
|
||||
version_files: &mut Vec<VersionFileBuilder>,
|
||||
dependencies: &mut Vec<DependencyBuilder>,
|
||||
cdn_url: &str,
|
||||
content_disposition: &actix_web::http::header::ContentDisposition,
|
||||
project_id: ProjectId,
|
||||
version_id: VersionId,
|
||||
@@ -943,13 +936,11 @@ pub async fn upload_file(
|
||||
|| total_files_len == 1;
|
||||
|
||||
let file_path_encode = format!(
|
||||
"data/{}/versions/{}/{}",
|
||||
project_id,
|
||||
version_id,
|
||||
"data/{project_id}/versions/{version_id}/{}",
|
||||
urlencoding::encode(file_name)
|
||||
);
|
||||
let file_path =
|
||||
format!("data/{}/versions/{}/{}", project_id, version_id, &file_name);
|
||||
format!("data/{project_id}/versions/{version_id}/{file_name}");
|
||||
|
||||
let upload_data = file_host
|
||||
.upload_file(content_type, &file_path, FileHostPublicity::Public, data)
|
||||
@@ -980,33 +971,9 @@ pub async fn upload_file(
|
||||
return Err(CreateError::InvalidInput(msg.to_string()));
|
||||
}
|
||||
|
||||
let url = format!("{cdn_url}/{file_path_encode}");
|
||||
|
||||
let client = reqwest::Client::new();
|
||||
let delphi_url = dotenvy::var("DELPHI_URL")?;
|
||||
match client
|
||||
.post(delphi_url)
|
||||
.json(&serde_json::json!({
|
||||
"url": url,
|
||||
"project_id": project_id,
|
||||
"version_id": version_id,
|
||||
}))
|
||||
.send()
|
||||
.await
|
||||
{
|
||||
Ok(res) => {
|
||||
if !res.status().is_success() {
|
||||
error!("Failed to upload file to Delphi: {url}");
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Failed to upload file to Delphi: {url}: {e}");
|
||||
}
|
||||
}
|
||||
|
||||
version_files.push(VersionFileBuilder {
|
||||
filename: file_name.to_string(),
|
||||
url: format!("{cdn_url}/{file_path_encode}"),
|
||||
url: format!("{}/{file_path_encode}", dotenvy::var("CDN_URL")?),
|
||||
hashes: vec![
|
||||
models::version_item::HashBuilder {
|
||||
algorithm: "sha1".to_string(),
|
||||
|
||||
Reference in New Issue
Block a user