Allow using Multiple Boss App IDs for WUP Files

This commit is contained in:
BloxerHD 2026-02-25 18:38:32 +00:00
commit f6897c30ac
9 changed files with 52 additions and 48 deletions

View file

@ -12,7 +12,7 @@ use crate::{crypto::wiiu::encrypt_wiiu, models::file_wup::FileWUPAttributes};
#[derive(Deserialize)]
pub struct UploadedWUP {
task_id: String,
boss_app_id: String,
boss_app_ids: Vec<String>,
supported_countries: Vec<String>,
supported_languages: Vec<String>,
name: Option<String>,
@ -54,7 +54,8 @@ pub async fn upload_file_wup(pool: &State<Pool>, input: Json<UploadedWUP>, auth:
if data.name == None && !data.name_equals_data_id { return Err(Status::BadRequest) };
let name = data.name.clone().unwrap();
if data.boss_app_id.len() != 16 { return Err(Status::BadRequest) };
for id in &data.boss_app_ids { if id.len() != 16 { return Err(Status::BadRequest); }; };
//if data.boss_app_id.len() != 16 { return Err(Status::BadRequest) };
if !is_valid_countries(&data.supported_countries) { return Err(Status::BadRequest) };
if !is_valid_languages(&data.supported_languages) { return Err(Status::BadRequest) };
@ -94,7 +95,8 @@ pub async fn upload_file_wup(pool: &State<Pool>, input: Json<UploadedWUP>, auth:
let hash_bytes = &hasher.finalize()[..];
let hash = hex::encode(hash_bytes);
let file_key = format!("{}/{}/{}", data.boss_app_id, data.task_id, hash);
//let file_key = format!("{}/{}/{}", data.boss_app_id, data.task_id, hash);
let file_key = format!("{}/{}", data.task_id, hash);
let _ = sqlx::query!(
r#"
@ -117,9 +119,9 @@ pub async fn upload_file_wup(pool: &State<Pool>, input: Json<UploadedWUP>, auth:
UPDATE files_wup
SET deleted = TRUE,
updated = NOW() AT TIME ZONE 'UTC'
WHERE boss_app_id = $1 AND task_id = $2 AND name = $3;
WHERE boss_app_ids = $1 AND task_id = $2 AND name = $3;
"#,
&data.boss_app_id,
&data.boss_app_ids,
&data.task_id,
name
)
@ -142,7 +144,7 @@ pub async fn upload_file_wup(pool: &State<Pool>, input: Json<UploadedWUP>, auth:
INSERT INTO files_wup (
file_key,
task_id,
boss_app_id,
boss_app_ids,
supported_countries,
supported_languages,
attributes,
@ -165,7 +167,7 @@ pub async fn upload_file_wup(pool: &State<Pool>, input: Json<UploadedWUP>, auth:
"#,
file_key,
data.task_id,
data.boss_app_id,
&data.boss_app_ids,
&data.supported_countries,
&data.supported_languages,
attributes,

View file

@ -59,8 +59,9 @@ pub async fn get_wup_task_files(
if !allow_deleted { qb.push(" AND deleted = false"); };
qb.push(" AND boss_app_id = ");
qb.push(" AND boss_app_ids @> ARRAY[");
qb.push_bind(boss_app_id);
qb.push("]");
qb.push(" AND task_id = ");
qb.push_bind(task_id);
@ -110,8 +111,9 @@ pub async fn get_wup_task_file(
if !allow_deleted { qb.push(" AND deleted = false"); };
qb.push(" AND boss_app_id = ");
qb.push(" AND boss_app_ids @> ARRAY[");
qb.push_bind(boss_app_id);
qb.push("]");
qb.push(" AND task_id = ");
qb.push_bind(&task_id[..7]);
@ -150,7 +152,7 @@ pub async fn get_wup_task_file_by_data_id(pool: &Pool, data_id: i64) -> Option<F
file_key,
data_id,
task_id,
boss_app_id,
boss_app_ids,
supported_countries,
supported_languages,
attributes AS "attributes!: Json<FileWUPAttributes>",

View file

@ -77,7 +77,7 @@ pub struct FileWUP {
pub file_key: String,
pub data_id: Option<i64>,
pub task_id: String,
pub boss_app_id: String,
pub boss_app_ids: Vec<String>,
pub supported_countries: Vec<String>,
pub supported_languages: Vec<String>,
pub attributes: Json<FileWUPAttributes>,

View file

@ -37,7 +37,7 @@ pub async fn data(pool: &State<Pool>, boss_app_id: String, data_id: i64, file_ha
None => return Err(Status::NotFound),
};
if file_wup.hash != file_hash || file_wup.boss_app_id != boss_app_id { return Err(Status::NotFound); }
if file_wup.hash != file_hash || !file_wup.boss_app_ids.contains(&boss_app_id) { return Err(Status::NotFound); }
let file = sqlx::query_scalar!(
"SELECT data FROM files WHERE key = $1",