diff --git a/src/main.rs b/src/main.rs index 491facd..4a1b469 100644 --- a/src/main.rs +++ b/src/main.rs @@ -85,6 +85,7 @@ fn main() { fn run(options: Options) -> Result<(), anyhow::Error> { let auth_cookie = options.auth_cookie.or_else(get_auth_cookie); + let api_key = options.api_key; match options.subcommand { Subcommand::Run { script, args } => { @@ -97,7 +98,7 @@ fn run(options: Options) -> Result<(), anyhow::Error> { .map(|value| value.to_lua(context)) .collect::, _>>()?; - RemodelContext::new(auth_cookie, options.api_key).inject(context)?; + RemodelContext::new(auth_cookie, api_key).inject(context)?; RemodelApi::inject(context)?; RobloxApi::inject(context)?; diff --git a/src/remodel_api/remodel.rs b/src/remodel_api/remodel.rs index c585c3a..17f5594 100644 --- a/src/remodel_api/remodel.rs +++ b/src/remodel_api/remodel.rs @@ -31,10 +31,7 @@ fn xml_decode_options() -> rbx_xml::DecodeOptions { pub enum UploadPlaceAsset { Legacy(u64), - CloudAPI { - place_id: u64, - universe_id: u64, - } + CloudAPI { place_id: u64, universe_id: u64 }, } pub struct Remodel; @@ -342,13 +339,24 @@ impl Remodel { match asset { UploadPlaceAsset::Legacy(asset_id) => Remodel::upload_asset(context, buffer, asset_id), - UploadPlaceAsset::CloudAPI {place_id, universe_id} => Remodel::cloud_upload_place_asset(context, buffer, universe_id, place_id), + UploadPlaceAsset::CloudAPI { + place_id, + universe_id, + } => Remodel::cloud_upload_place_asset(context, buffer, universe_id, place_id), } } - fn cloud_upload_place_asset(context: Context<'_>, buffer: Vec, universe_id: u64, asset_id: u64) -> rlua::Result<()> { + fn cloud_upload_place_asset( + context: Context<'_>, + buffer: Vec, + universe_id: u64, + asset_id: u64, + ) -> rlua::Result<()> { let re_context = RemodelContext::get(context)?; - let url = format!("https://apis.roblox.com/universes/v1/{}/places/{}/versions?versionType=Published", universe_id, asset_id); + let url = format!( + "https://apis.roblox.com/universes/v1/{}/places/{}/versions?versionType=Published", + universe_id, asset_id + ); let api_key = re_context.api_key().ok_or_else(|| { rlua::Error::external( @@ -365,13 +373,12 @@ impl Remodel { client .post(&url) .header("x-api-key", api_key) - .header(USER_AGENT, "Roblox/WinInet") .header(CONTENT_TYPE, "application/xml") .header(ACCEPT, "application/json") .body(buffer.clone()) }; - log::debug!("Uploading to Roblox..."); + log::debug!("Uploading to Roblox Cloud..."); let response = build_request().send().map_err(rlua::Error::external)?; if response.status().is_success() { @@ -545,15 +552,26 @@ impl UserData for Remodel { |context, (instance, asset_id): (LuaInstance, String)| { let asset_id = asset_id.parse().map_err(rlua::Error::external)?; - Remodel::write_existing_place_asset(context, instance, UploadPlaceAsset::Legacy(asset_id)) + Remodel::write_existing_place_asset( + context, + instance, + UploadPlaceAsset::Legacy(asset_id), + ) }, ); methods.add_function( "publishPlaceToCloud", |context, (instance, universe_id, place_id): (LuaInstance, u64, u64)| { - Remodel::write_existing_place_asset(context, instance, UploadPlaceAsset::CloudAPI {universe_id, place_id}) - } + Remodel::write_existing_place_asset( + context, + instance, + UploadPlaceAsset::CloudAPI { + universe_id, + place_id, + }, + ) + }, ); methods.add_function(