validation: plumb group id into publish functions
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
ec414a0f42
commit
cb736628d7
@ -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
|
||||
|
@ -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<u64>=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");
|
||||
|
@ -26,12 +26,13 @@ pub struct MessageHandler{
|
||||
impl MessageHandler{
|
||||
pub fn new(
|
||||
cookie_context:rbx_asset::cookie::CookieContext,
|
||||
group_id:Option<u64>,
|
||||
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),
|
||||
}
|
||||
}
|
||||
|
@ -17,15 +17,18 @@ impl std::error::Error for PublishError{}
|
||||
|
||||
pub struct Publisher{
|
||||
roblox_cookie:rbx_asset::cookie::CookieContext,
|
||||
group_id:Option<u64>,
|
||||
api_internal:submissions_api::internal::Context,
|
||||
}
|
||||
impl Publisher{
|
||||
pub const fn new(
|
||||
roblox_cookie:rbx_asset::cookie::CookieContext,
|
||||
group_id:Option<u64>,
|
||||
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,
|
||||
|
@ -18,15 +18,18 @@ impl std::error::Error for PublishError{}
|
||||
|
||||
pub struct Publisher{
|
||||
roblox_cookie:rbx_asset::cookie::CookieContext,
|
||||
group_id:Option<u64>,
|
||||
api:submissions_api::internal::Context,
|
||||
}
|
||||
impl Publisher{
|
||||
pub const fn new(
|
||||
roblox_cookie:rbx_asset::cookie::CookieContext,
|
||||
group_id:Option<u64>,
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user