MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / publish_mod

Function publish_mod

mserver/MasterService/src/http.rs:433–527  ·  view source on GitHub ↗

Publish a packed mod to the workshop. Admin-gated (`x-api-key`); accepts a `multipart/form-data` body with a `name` field, an optional `version`/`description`/ `homepageUrl`, repeated `author` fields, and the PBO as the `file` field.

(
    State(state): State<AppState>,
    headers: HeaderMap,
    mut multipart: Multipart,
)

Source from the content-addressed store, hash-verified

431 Ok(Json(records))
432}
433
434#[utoipa::path(
435 get,
436 path = "/v1/mods/{modId}/servers",
437 params(
438 ("modId" = String, Path, description = "Mod identifier")
439 ),
440 responses(
441 (status = 200, description = "Servers currently using this mod", body = [ModUsageServer])
442 )
443)]
444async fn list_mod_servers(
445 State(state): State<AppState>,
446 Path(mod_id): Path<String>,
447) -> Result<Json<Vec<ModUsageServer>>, (StatusCode, String)> {
448 let records = state
449 .service
450 .mod_usage_servers(&mod_id)
451 .await
452 .map_err(|error| internal_error(&error))?;
453 Ok(Json(records))
454}
455
456/// Publish a packed mod to the workshop. Admin-gated (`x-api-key`); accepts a
457/// `multipart/form-data` body with a `name` field, optional `app`/`actver`/`vertag`,
458/// optional `version`/`description`/`homepageUrl`, repeated `author` fields, and the PBO
459/// as the `file` field.
460async fn publish_mod(
461 State(state): State<AppState>,
462 headers: HeaderMap,
463 mut multipart: Multipart,
464) -> Result<Json<ModCatalogEntry>, (StatusCode, String)> {
465 require_admin_api_key(&state, &headers)?;
466 if !state.service.mods_enabled() {
467 return Err((
468 StatusCode::SERVICE_UNAVAILABLE,
469 "mods directory is not configured".to_string(),
470 ));
471 }
472
473 let Some(mut upload) = state
474 .service
475 .begin_mod_upload()
476 .await
477 .map_err(|error| internal_error(&error))?
478 else {
479 return Err((
480 StatusCode::SERVICE_UNAVAILABLE,
481 "mods directory is not configured".to_string(),
482 ));
483 };
484
485 let mut name: Option<String> = None;
486 let mut app_name: Option<String> = None;
487 let mut actver: Option<String> = None;
488 let mut version_tag: Option<String> = None;
489 let mut version: Option<String> = None;
490 let mut folder_name: Option<String> = None;

Callers

nothing calls this directly

Calls 9

require_admin_api_keyFunction · 0.85
internal_errorFunction · 0.85
read_text_fieldFunction · 0.85
mods_enabledMethod · 0.80
begin_mod_uploadMethod · 0.80
pushMethod · 0.80
okMethod · 0.80
finalize_mod_uploadMethod · 0.80
writeMethod · 0.45

Tested by

no test coverage detected