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:
|
env_file:
|
||||||
- ../auth-compose/strafesnet.env
|
- ../auth-compose/strafesnet.env
|
||||||
environment:
|
environment:
|
||||||
|
- ROBLOX_GROUP_ID=None # special case string value
|
||||||
- API_HOST=http://submissions:8082
|
- API_HOST=http://submissions:8082
|
||||||
- API_HOST_INTERNAL=http://submissions:8083
|
- API_HOST_INTERNAL=http://submissions:8083
|
||||||
- NATS_HOST=nats:4222
|
- NATS_HOST=nats:4222
|
||||||
|
@ -23,12 +23,18 @@ impl std::fmt::Display for StartupError{
|
|||||||
}
|
}
|
||||||
impl std::error::Error for StartupError{}
|
impl std::error::Error for StartupError{}
|
||||||
|
|
||||||
pub const GROUP_STRAFESNET:u64=6980477;
|
|
||||||
|
|
||||||
pub const PARALLEL_REQUESTS:usize=16;
|
pub const PARALLEL_REQUESTS:usize=16;
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main()->Result<(),StartupError>{
|
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
|
// talk to roblox through STRAFESNET_CI2 account
|
||||||
let cookie=std::env::var("RBXCOOKIE").expect("RBXCOOKIE env required");
|
let cookie=std::env::var("RBXCOOKIE").expect("RBXCOOKIE env required");
|
||||||
let cookie_context=rbx_asset::cookie::CookieContext::new(rbx_asset::cookie::Cookie::new(cookie));
|
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)
|
.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
|
// 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");
|
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{
|
impl MessageHandler{
|
||||||
pub fn new(
|
pub fn new(
|
||||||
cookie_context:rbx_asset::cookie::CookieContext,
|
cookie_context:rbx_asset::cookie::CookieContext,
|
||||||
|
group_id:Option<u64>,
|
||||||
api:submissions_api::external::Context,
|
api:submissions_api::external::Context,
|
||||||
api_internal:submissions_api::internal::Context,
|
api_internal:submissions_api::internal::Context,
|
||||||
)->Self{
|
)->Self{
|
||||||
Self{
|
Self{
|
||||||
publish_new:crate::publish_new::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(),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),
|
validator:crate::validator::Validator::new(cookie_context,api,api_internal),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,15 +17,18 @@ impl std::error::Error for PublishError{}
|
|||||||
|
|
||||||
pub struct Publisher{
|
pub struct Publisher{
|
||||||
roblox_cookie:rbx_asset::cookie::CookieContext,
|
roblox_cookie:rbx_asset::cookie::CookieContext,
|
||||||
|
group_id:Option<u64>,
|
||||||
api_internal:submissions_api::internal::Context,
|
api_internal:submissions_api::internal::Context,
|
||||||
}
|
}
|
||||||
impl Publisher{
|
impl Publisher{
|
||||||
pub const fn new(
|
pub const fn new(
|
||||||
roblox_cookie:rbx_asset::cookie::CookieContext,
|
roblox_cookie:rbx_asset::cookie::CookieContext,
|
||||||
|
group_id:Option<u64>,
|
||||||
api_internal:submissions_api::internal::Context,
|
api_internal:submissions_api::internal::Context,
|
||||||
)->Self{
|
)->Self{
|
||||||
Self{
|
Self{
|
||||||
roblox_cookie,
|
roblox_cookie,
|
||||||
|
group_id,
|
||||||
api_internal,
|
api_internal,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -43,7 +46,7 @@ impl Publisher{
|
|||||||
// upload the map to the strafesnet group
|
// upload the map to the strafesnet group
|
||||||
let _upload_response=self.roblox_cookie.upload(rbx_asset::cookie::UploadRequest{
|
let _upload_response=self.roblox_cookie.upload(rbx_asset::cookie::UploadRequest{
|
||||||
assetid:publish_info.TargetAssetID,
|
assetid:publish_info.TargetAssetID,
|
||||||
groupId:Some(crate::GROUP_STRAFESNET),
|
groupId:self.group_id,
|
||||||
name:None,
|
name:None,
|
||||||
description:None,
|
description:None,
|
||||||
ispublic:None,
|
ispublic:None,
|
||||||
|
@ -18,15 +18,18 @@ impl std::error::Error for PublishError{}
|
|||||||
|
|
||||||
pub struct Publisher{
|
pub struct Publisher{
|
||||||
roblox_cookie:rbx_asset::cookie::CookieContext,
|
roblox_cookie:rbx_asset::cookie::CookieContext,
|
||||||
|
group_id:Option<u64>,
|
||||||
api:submissions_api::internal::Context,
|
api:submissions_api::internal::Context,
|
||||||
}
|
}
|
||||||
impl Publisher{
|
impl Publisher{
|
||||||
pub const fn new(
|
pub const fn new(
|
||||||
roblox_cookie:rbx_asset::cookie::CookieContext,
|
roblox_cookie:rbx_asset::cookie::CookieContext,
|
||||||
|
group_id:Option<u64>,
|
||||||
api:submissions_api::internal::Context,
|
api:submissions_api::internal::Context,
|
||||||
)->Self{
|
)->Self{
|
||||||
Self{
|
Self{
|
||||||
roblox_cookie,
|
roblox_cookie,
|
||||||
|
group_id,
|
||||||
api,
|
api,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -47,7 +50,7 @@ impl Publisher{
|
|||||||
description:"".to_owned(),
|
description:"".to_owned(),
|
||||||
ispublic:false,
|
ispublic:false,
|
||||||
allowComments:false,
|
allowComments:false,
|
||||||
groupId:Some(crate::GROUP_STRAFESNET),
|
groupId:self.group_id,
|
||||||
},model_data).await.map_err(PublishError::Create)?;
|
},model_data).await.map_err(PublishError::Create)?;
|
||||||
|
|
||||||
// note the asset id of the created model for later release, and mark the submission as uploaded
|
// 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