Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,063 changes: 946 additions & 117 deletions Cargo.lock

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ lettre = { version = "0.11.19", default-features = false, features = [
"tokio1",
"tokio1-rustls",
] }
lingua = "=1.8.0"
linkify = "0.11.0"
lz4_flex = { version = "0.11.5", default-features = false, features = [
"checked-decode",
Expand Down Expand Up @@ -154,7 +155,8 @@ postcard = { version = "1.1.3", default-features = false, features = ["alloc"] }
postcard-bindgen = "0.8.0"
proc-macro2 = { version = "1.0" }
prometheus = "0.14.0"
psl = "2.1.226"
psl = "2.1.145"
pulldown-cmark = { version = "0.13.4", default-features = false }
quartz_nbt = "0.2.9"
quick-xml = "0.38.3"
quote = { version = "1.0" }
Expand Down Expand Up @@ -247,7 +249,6 @@ webauthn-rs = "0.5.5"
webauthn-rs-proto = "0.5.5"
webp = { version = "0.3.1", default-features = false }
webview2-com = "0.38.0" # Should be updated in lockstep with wry
whatlang = "0.18.0"
whoami = "1.6.1"
windows = "=0.61.3" # Locked on 0.61 until we can update windows-core to 0.62
windows-core = "=0.61.2" # Locked on 0.61 until webview2-com updates to 0.62
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ import {
type MessageDescriptor,
useVIntl,
} from '@modrinth/ui'
import { isStaff } from '@modrinth/utils'
import type { Component } from 'vue'
import { computed, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue'

Expand Down Expand Up @@ -222,6 +223,7 @@ const messages = defineMessages({

const { formatMessage } = useVIntl()
const { addNotification } = injectNotificationManager()
const flags = useFeatureFlags()

const props = withDefaults(defineProps<Props>(), {
versions: () => [],
Expand Down Expand Up @@ -419,6 +421,15 @@ function isNagComplete(nag: Nag): boolean {
const visibleNags = computed<Nag[]>(() => {
const finalNags = applicableNags.value.filter((nag) => !isNagComplete(nag))

if (
isProcessing.value &&
isStaff(props.currentMember?.user) &&
!flags.value.alwaysShowPublishingChecklistForStaff &&
!finalNags.some((nag) => nag.status === 'required')
) {
return []
}

if (props.project.status === 'draft') {
finalNags.push({
id: 'submit-for-review',
Expand Down
1 change: 1 addition & 0 deletions apps/frontend/src/composables/featureFlags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export const DEFAULT_FEATURE_FLAGS = validateValues({
alwaysIgnoreErrorBanner: false,
showViewProdRouteBanner: false,
showModeratorProjectMemberUi: false,
alwaysShowPublishingChecklistForStaff: false,
archonApiStaging: false,
showHostingAccessInstanceAuditLog: false,
versionDevInfoCollapsed: true,
Expand Down
3 changes: 2 additions & 1 deletion apps/labrinth/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ image = { workspace = true, features = [
itertools = { workspace = true }
json-patch = { workspace = true }
lettre = { workspace = true }
lingua = { workspace = true }
linkify = { workspace = true }
modrinth-content-management = { workspace = true }
modrinth-util = { workspace = true, features = ["decimal", "sentry", "utoipa"] }
Expand All @@ -83,6 +84,7 @@ path-util = { workspace = true }
postcard = { workspace = true }
prometheus = { workspace = true }
psl = { workspace = true }
pulldown-cmark = { workspace = true }
quick-xml = { workspace = true }
rand = { workspace = true }
rand_chacha = { workspace = true }
Expand Down Expand Up @@ -137,7 +139,6 @@ webauthn-rs = { workspace = true, features = [
] }
webauthn-rs-proto = { workspace = true }
webp = { workspace = true }
whatlang = { workspace = true }
woothee = { workspace = true }
xredis = { workspace = true }
yaserde = { workspace = true, features = ["derive"] }
Expand Down
14 changes: 14 additions & 0 deletions apps/labrinth/fixtures/dummy_data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,20 @@ INSERT INTO loaders_project_types (joining_loader_id, joining_project_type_id) V

INSERT INTO loaders (id, loader, metadata) VALUES (7, 'bukkit', '{"platform":false}'::JSONB);
INSERT INTO loaders (id, loader, metadata) VALUES (8, 'waterfall', '{"platform":true}'::JSONB);
INSERT INTO loaders (id, loader) VALUES (9, 'datapack');

INSERT INTO loaders_project_types (joining_loader_id, joining_project_type_id)
SELECT l.id, pt.id
FROM loaders l
CROSS JOIN project_types pt
WHERE
(l.loader IN ('bukkit', 'waterfall') AND pt.name = 'plugin')
OR (l.loader = 'datapack' AND pt.name = 'datapack');

INSERT INTO loaders_project_types_games (loader_id, project_type_id, game_id)
SELECT lpt.joining_loader_id, lpt.joining_project_type_id, 1
FROM loaders_project_types lpt
WHERE lpt.joining_loader_id IN (7, 8, 9);

-- Adds dummies to mrpack_loaders
INSERT INTO loader_field_enum_values (enum_id, value)
Expand Down
28 changes: 18 additions & 10 deletions apps/labrinth/src/routes/v3/projects/validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,17 @@ pub(crate) async fn ensure_project_is_valid_for_review(
.collect::<Vec<_>>();
let project = Project::from(reloaded_project.clone());

if has_required_nags_with_context(
&project,
&versions,
&available_categories,
&disclosures,
) {
let has_required_nags = web::block(move || {
has_required_nags_with_context(
&project,
&versions,
&available_categories,
&disclosures,
)
})
.await
.wrap_internal_err("validating project for review")?;
if has_required_nags {
return Err(ApiError::Request(eyre!(
"project must have no required validation nags before or while under review"
)));
Expand Down Expand Up @@ -157,12 +162,15 @@ pub async fn validate(
.collect::<Vec<_>>();
let project = Project::from(project);

Ok(web::Json(ProjectValidationResponse {
nags: validate_project(
let nags = web::block(move || {
validate_project(
&project,
&versions,
&available_categories,
&disclosures,
),
}))
)
})
.await
.wrap_internal_err("validating project")?;
Ok(web::Json(ProjectValidationResponse { nags }))
}
67 changes: 66 additions & 1 deletion apps/labrinth/src/test/dummy_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use super::{

use super::{database::USER_USER_ID, get_json_val_str};

pub const DUMMY_DATA_UPDATE: i64 = 8;
pub const DUMMY_DATA_UPDATE: i64 = 9;

pub const DUMMY_CATEGORIES: &[&str] = &[
"combat",
Expand All @@ -47,6 +47,8 @@ pub enum TestFile {
// and BasicModRandom.bytes() will return a different file each time.
BasicModRandom { filename: String, bytes: Vec<u8> },
BasicModpackRandom { filename: String, bytes: Vec<u8> },
BasicPluginRandom { filename: String, bytes: Vec<u8> },
BasicDatapackRandom { filename: String, bytes: Vec<u8> },
}

impl TestFile {
Expand Down Expand Up @@ -163,6 +165,59 @@ impl TestFile {

TestFile::BasicModpackRandom { filename, bytes }
}

pub fn build_random_plugin() -> Self {
let filename = format!("random-plugin-{}.jar", rand::random::<u64>());
let plugin_yml =
"name: TestPlugin\nversion: 1.0.0\nmain: com.example.TestPlugin\n";

let mut cursor = Cursor::new(Vec::new());
{
let mut zip = ZipWriter::new(&mut cursor);
zip.start_file(
"plugin.yml",
FileOptions::<()>::default()
.compression_method(CompressionMethod::Stored),
)
.unwrap();
zip.write_all(plugin_yml.as_bytes()).unwrap();
zip.finish().unwrap();
}

TestFile::BasicPluginRandom {
filename,
bytes: cursor.into_inner(),
}
}

pub fn build_random_datapack() -> Self {
let filename = format!("random-datapack-{}.zip", rand::random::<u64>());
let pack_mcmeta = serde_json::json!({
"pack": {
"pack_format": 15,
"description": "Test datapack"
}
})
.to_string();

let mut cursor = Cursor::new(Vec::new());
{
let mut zip = ZipWriter::new(&mut cursor);
zip.start_file(
"pack.mcmeta",
FileOptions::<()>::default()
.compression_method(CompressionMethod::Stored),
)
.unwrap();
zip.write_all(pack_mcmeta.as_bytes()).unwrap();
zip.finish().unwrap();
}

TestFile::BasicDatapackRandom {
filename,
bytes: cursor.into_inner(),
}
}
}

#[derive(Clone)]
Expand Down Expand Up @@ -472,6 +527,8 @@ impl TestFile {
TestFile::BasicModDifferent => "basic-mod-different.jar",
TestFile::BasicModRandom { filename, .. } => filename,
TestFile::BasicModpackRandom { filename, .. } => filename,
TestFile::BasicPluginRandom { filename, .. } => filename,
TestFile::BasicDatapackRandom { filename, .. } => filename,
}
.to_string()
}
Expand All @@ -498,6 +555,8 @@ impl TestFile {
}
TestFile::BasicModRandom { bytes, .. } => bytes.clone(),
TestFile::BasicModpackRandom { bytes, .. } => bytes.clone(),
TestFile::BasicPluginRandom { bytes, .. } => bytes.clone(),
TestFile::BasicDatapackRandom { bytes, .. } => bytes.clone(),
}
}

Expand All @@ -512,6 +571,8 @@ impl TestFile {
TestFile::BasicZip => "resourcepack",

TestFile::BasicModpackRandom { .. } => "modpack",
TestFile::BasicPluginRandom { .. } => "plugin",
TestFile::BasicDatapackRandom { .. } => "datapack",
}
.to_string()
}
Expand All @@ -529,6 +590,10 @@ impl TestFile {
TestFile::BasicModpackRandom { .. } => {
Some("application/x-modrinth-modpack+zip")
}
TestFile::BasicPluginRandom { .. } => {
Some("application/java-archive")
}
TestFile::BasicDatapackRandom { .. } => Some("application/zip"),
}
.map(|s| s.to_string())
}
Expand Down
Loading
Loading