Skip to content

Commit

Permalink
add replacements for mods that aren't on index
Browse files Browse the repository at this point in the history
  • Loading branch information
Fleeym committed May 31, 2024
1 parent 4f2eac6 commit a2168b3
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/endpoints/mods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,17 +141,33 @@ pub async fn get_mod_updates(
let platforms: Vec<VerPlatform> = vec![];

let mut result: Vec<ModUpdate> = Mod::get_updates(&ids, platforms, &mut pool).await?;
let replacements = Incompatibility::get_supersedes_for(&ids, &mut pool).await?;
let mut replacements = Incompatibility::get_supersedes_for(&ids, &mut pool).await?;

for i in &mut result {
if let Some(replacement) = replacements.get(&i.id) {
let mut clone = replacement.clone();
clone.download_link = create_download_link(&data.app_url, &clone.id, &clone.version);
i.replacement = Some(clone);
replacements.remove_entry(&i.id);
}
i.download_link = create_download_link(&data.app_url, &i.id, &i.version);
}

for i in replacements {
let mut replacement = i.1.clone();
replacement.download_link =
create_download_link(&data.app_url, &replacement.id, &replacement.version);
result.push(ModUpdate {
id: i.0.clone(),
version: "1.0.0".to_string(),
mod_version_id: 0,
download_link: replacement.download_link.clone(),
replacement: Some(replacement),
dependencies: vec![],
incompatibilities: vec![],
});
}

Ok(web::Json(ApiResponse {
error: "".into(),
payload: result,
Expand Down

0 comments on commit a2168b3

Please sign in to comment.