From cb736628d71e4e5730d4f990e85c01700d36a5b0 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Sun, 15 Dec 2024 02:17:45 -0800 Subject: [PATCH] validation: plumb group id into publish functions --- compose.yaml | 1 + validation/src/main.rs | 12 +++++++++--- validation/src/message_handler.rs | 5 +++-- validation/src/publish_fix.rs | 5 ++++- validation/src/publish_new.rs | 5 ++++- 5 files changed, 21 insertions(+), 7 deletions(-) diff --git a/compose.yaml b/compose.yaml index 554ec9f..b1ee3d3 100644 --- a/compose.yaml +++ b/compose.yaml @@ -55,6 +55,7 @@ services: env_file: - ../auth-compose/strafesnet.env environment: + - ROBLOX_GROUP_ID=None # special case string value - API_HOST=http://submissions:8082 - API_HOST_INTERNAL=http://submissions:8083 - NATS_HOST=nats:4222 diff --git a/validation/src/main.rs b/validation/src/main.rs index 4c0a4f0..d419da2 100644 --- a/validation/src/main.rs +++ b/validation/src/main.rs @@ -23,12 +23,18 @@ impl std::fmt::Display for StartupError{ } impl std::error::Error for StartupError{} -pub const GROUP_STRAFESNET:u64=6980477; - pub const PARALLEL_REQUESTS:usize=16; #[tokio::main] async fn main()->Result<(),StartupError>{ + let group_id:Option=match std::env::var("ROBLOX_GROUP_ID"){ + Ok(s)=>match s.as_str(){ + "None"=>None, + _=>Some(s.parse().expect("ROBLOX_GROUP_ID int parse")), + }, + Err(e)=>Err(e).expect("ROBLOX_GROUP_ID env required"), + }; + // talk to roblox through STRAFESNET_CI2 account let cookie=std::env::var("RBXCOOKIE").expect("RBXCOOKIE env required"); let cookie_context=rbx_asset::cookie::CookieContext::new(rbx_asset::cookie::Cookie::new(cookie)); @@ -56,7 +62,7 @@ async fn main()->Result<(),StartupError>{ .messages().await.map_err(StartupError::NatsStream) }; - let message_handler=message_handler::MessageHandler::new(cookie_context,api,api_internal); + let message_handler=message_handler::MessageHandler::new(cookie_context,group_id,api,api_internal); // Create a signal listener for SIGTERM let mut sig_term=tokio::signal::unix::signal(tokio::signal::unix::SignalKind::terminate()).expect("Failed to create SIGTERM signal listener"); diff --git a/validation/src/message_handler.rs b/validation/src/message_handler.rs index 3d76870..3e1ee13 100644 --- a/validation/src/message_handler.rs +++ b/validation/src/message_handler.rs @@ -26,12 +26,13 @@ pub struct MessageHandler{ impl MessageHandler{ pub fn new( cookie_context:rbx_asset::cookie::CookieContext, + group_id:Option, api:submissions_api::external::Context, api_internal:submissions_api::internal::Context, )->Self{ Self{ - publish_new:crate::publish_new::Publisher::new(cookie_context.clone(),api_internal.clone()), - publish_fix:crate::publish_fix::Publisher::new(cookie_context.clone(),api_internal.clone()), + publish_new:crate::publish_new::Publisher::new(cookie_context.clone(),group_id,api_internal.clone()), + publish_fix:crate::publish_fix::Publisher::new(cookie_context.clone(),group_id,api_internal.clone()), validator:crate::validator::Validator::new(cookie_context,api,api_internal), } } diff --git a/validation/src/publish_fix.rs b/validation/src/publish_fix.rs index c7d9a3d..2602618 100644 --- a/validation/src/publish_fix.rs +++ b/validation/src/publish_fix.rs @@ -17,15 +17,18 @@ impl std::error::Error for PublishError{} pub struct Publisher{ roblox_cookie:rbx_asset::cookie::CookieContext, + group_id:Option, api_internal:submissions_api::internal::Context, } impl Publisher{ pub const fn new( roblox_cookie:rbx_asset::cookie::CookieContext, + group_id:Option, api_internal:submissions_api::internal::Context, )->Self{ Self{ roblox_cookie, + group_id, api_internal, } } @@ -43,7 +46,7 @@ impl Publisher{ // upload the map to the strafesnet group let _upload_response=self.roblox_cookie.upload(rbx_asset::cookie::UploadRequest{ assetid:publish_info.TargetAssetID, - groupId:Some(crate::GROUP_STRAFESNET), + groupId:self.group_id, name:None, description:None, ispublic:None, diff --git a/validation/src/publish_new.rs b/validation/src/publish_new.rs index 30be17b..e9c71da 100644 --- a/validation/src/publish_new.rs +++ b/validation/src/publish_new.rs @@ -18,15 +18,18 @@ impl std::error::Error for PublishError{} pub struct Publisher{ roblox_cookie:rbx_asset::cookie::CookieContext, + group_id:Option, api:submissions_api::internal::Context, } impl Publisher{ pub const fn new( roblox_cookie:rbx_asset::cookie::CookieContext, + group_id:Option, api:submissions_api::internal::Context, )->Self{ Self{ roblox_cookie, + group_id, api, } } @@ -47,7 +50,7 @@ impl Publisher{ description:"".to_owned(), ispublic:false, allowComments:false, - groupId:Some(crate::GROUP_STRAFESNET), + groupId:self.group_id, },model_data).await.map_err(PublishError::Create)?; // note the asset id of the created model for later release, and mark the submission as uploaded