rename part 2: rename all occurrences of "publish" to "upload"

This commit is contained in:
Quaternions 2025-03-28 15:51:39 -07:00
parent e855ace229
commit f3689f4916
Signed by: Quaternions
GPG Key ID: D0DF5964F79AC131
6 changed files with 47 additions and 47 deletions

@ -14,14 +14,14 @@ type ValidateRequest struct {
} }
// Create a new map // Create a new map
type PublishNewRequest struct { type UploadNewRequest struct {
SubmissionID int64 SubmissionID int64
ModelID int64 ModelID int64
ModelVersion int64 ModelVersion int64
ModelName string ModelName string
} }
type PublishFixRequest struct { type UploadFixRequest struct {
SubmissionID int64 SubmissionID int64
ModelID int64 ModelID int64
ModelVersion int64 ModelVersion int64

@ -424,35 +424,35 @@ func (svc *Service) ActionSubmissionTriggerUpload(ctx context.Context, params ap
// sentinel value because we are not using rust // sentinel value because we are not using rust
if submission.TargetAssetID == 0 { if submission.TargetAssetID == 0 {
// this is a new map // this is a new map
publish_new_request := model.PublishNewRequest{ upload_new_request := model.UploadNewRequest{
SubmissionID: submission.ID, SubmissionID: submission.ID,
ModelID: submission.ValidatedAssetID, ModelID: submission.ValidatedAssetID,
ModelVersion: submission.ValidatedAssetVersion, ModelVersion: submission.ValidatedAssetVersion,
// publish as displayname, whatever // upload as displayname, whatever
ModelName: submission.DisplayName, ModelName: submission.DisplayName,
} }
j, err := json.Marshal(publish_new_request) j, err := json.Marshal(upload_new_request)
if err != nil { if err != nil {
return err return err
} }
svc.Nats.Publish("maptest.submissions.publishnew", []byte(j)) svc.Nats.Publish("maptest.submissions.uploadnew", []byte(j))
} else { } else {
// this is a map fix // this is a map fix
publish_fix_request := model.PublishFixRequest{ upload_fix_request := model.UploadFixRequest{
SubmissionID: submission.ID, SubmissionID: submission.ID,
ModelID: submission.ValidatedAssetID, ModelID: submission.ValidatedAssetID,
ModelVersion: submission.ValidatedAssetVersion, ModelVersion: submission.ValidatedAssetVersion,
TargetAssetID: submission.TargetAssetID, TargetAssetID: submission.TargetAssetID,
} }
j, err := json.Marshal(publish_fix_request) j, err := json.Marshal(upload_fix_request)
if err != nil { if err != nil {
return err return err
} }
svc.Nats.Publish("maptest.submissions.publishfix", []byte(j)) svc.Nats.Publish("maptest.submissions.uploadfix", []byte(j))
} }
return nil return nil

@ -5,8 +5,8 @@ pub enum HandleMessageError{
DoubleAck(async_nats::Error), DoubleAck(async_nats::Error),
Json(serde_json::Error), Json(serde_json::Error),
UnknownSubject(String), UnknownSubject(String),
PublishNew(crate::upload_new::PublishError), UploadNew(crate::upload_new::UploadError),
PublishFix(crate::upload_fix::PublishError), UploadFix(crate::upload_fix::UploadError),
Validation(crate::validator::ValidateError), Validation(crate::validator::ValidateError),
} }
impl std::fmt::Display for HandleMessageError{ impl std::fmt::Display for HandleMessageError{
@ -23,8 +23,8 @@ fn from_slice<'a,T:serde::de::Deserialize<'a>>(slice:&'a [u8])->Result<T,HandleM
} }
pub struct MessageHandler{ pub struct MessageHandler{
publish_new:crate::upload_new::Publisher, upload_new:crate::upload_new::Uploader,
publish_fix:crate::upload_fix::Publisher, upload_fix:crate::upload_fix::Uploader,
validator:crate::validator::Validator, validator:crate::validator::Validator,
} }
@ -35,8 +35,8 @@ impl MessageHandler{
api:submissions_api::internal::Context, api:submissions_api::internal::Context,
)->Self{ )->Self{
Self{ Self{
publish_new:crate::upload_new::Publisher::new(cookie_context.clone(),group_id,api.clone()), upload_new:crate::upload_new::Uploader::new(cookie_context.clone(),group_id,api.clone()),
publish_fix:crate::upload_fix::Publisher::new(cookie_context.clone(),group_id,api.clone()), upload_fix:crate::upload_fix::Uploader::new(cookie_context.clone(),group_id,api.clone()),
validator:crate::validator::Validator::new(cookie_context,api), validator:crate::validator::Validator::new(cookie_context,api),
} }
} }
@ -44,8 +44,8 @@ impl MessageHandler{
let message=message_result.map_err(HandleMessageError::Messages)?; let message=message_result.map_err(HandleMessageError::Messages)?;
message.double_ack().await.map_err(HandleMessageError::DoubleAck)?; message.double_ack().await.map_err(HandleMessageError::DoubleAck)?;
match message.subject.as_str(){ match message.subject.as_str(){
"maptest.submissions.publishnew"=>self.publish_new.publish(from_slice(&message.payload)?).await.map_err(HandleMessageError::PublishNew), "maptest.submissions.uploadnew"=>self.upload_new.upload(from_slice(&message.payload)?).await.map_err(HandleMessageError::UploadNew),
"maptest.submissions.publishfix"=>self.publish_fix.publish(from_slice(&message.payload)?).await.map_err(HandleMessageError::PublishFix), "maptest.submissions.uploadfix"=>self.upload_fix.upload(from_slice(&message.payload)?).await.map_err(HandleMessageError::UploadFix),
"maptest.submissions.validate"=>self.validator.validate(from_slice(&message.payload)?).await.map_err(HandleMessageError::Validation), "maptest.submissions.validate"=>self.validator.validate(from_slice(&message.payload)?).await.map_err(HandleMessageError::Validation),
other=>Err(HandleMessageError::UnknownSubject(other.to_owned())) other=>Err(HandleMessageError::UnknownSubject(other.to_owned()))
} }

@ -17,7 +17,7 @@ pub struct ValidateRequest{
// Create a new map // Create a new map
#[allow(nonstandard_style)] #[allow(nonstandard_style)]
#[derive(serde::Deserialize)] #[derive(serde::Deserialize)]
pub struct PublishNewRequest{ pub struct UploadNewRequest{
pub SubmissionID:i64, pub SubmissionID:i64,
pub ModelID:u64, pub ModelID:u64,
pub ModelVersion:u64, pub ModelVersion:u64,
@ -26,7 +26,7 @@ pub struct PublishNewRequest{
#[allow(nonstandard_style)] #[allow(nonstandard_style)]
#[derive(serde::Deserialize)] #[derive(serde::Deserialize)]
pub struct PublishFixRequest{ pub struct UploadFixRequest{
pub SubmissionID:i64, pub SubmissionID:i64,
pub ModelID:u64, pub ModelID:u64,
pub ModelVersion:u64, pub ModelVersion:u64,

@ -1,26 +1,26 @@
use crate::nats_types::PublishFixRequest; use crate::nats_types::UploadFixRequest;
#[allow(dead_code)] #[allow(dead_code)]
#[derive(Debug)] #[derive(Debug)]
pub enum PublishError{ pub enum UploadError{
Get(rbx_asset::cookie::GetError), Get(rbx_asset::cookie::GetError),
Json(serde_json::Error), Json(serde_json::Error),
Upload(rbx_asset::cookie::UploadError), Upload(rbx_asset::cookie::UploadError),
ApiActionSubmissionUploaded(submissions_api::Error), ApiActionSubmissionUploaded(submissions_api::Error),
} }
impl std::fmt::Display for PublishError{ impl std::fmt::Display for UploadError{
fn fmt(&self,f:&mut std::fmt::Formatter<'_>)->std::fmt::Result{ fn fmt(&self,f:&mut std::fmt::Formatter<'_>)->std::fmt::Result{
write!(f,"{self:?}") write!(f,"{self:?}")
} }
} }
impl std::error::Error for PublishError{} impl std::error::Error for UploadError{}
pub struct Publisher{ pub struct Uploader{
roblox_cookie:rbx_asset::cookie::CookieContext, roblox_cookie:rbx_asset::cookie::CookieContext,
group_id:Option<u64>, group_id:Option<u64>,
api_internal:submissions_api::internal::Context, api_internal:submissions_api::internal::Context,
} }
impl Publisher{ impl Uploader{
pub const fn new( pub const fn new(
roblox_cookie:rbx_asset::cookie::CookieContext, roblox_cookie:rbx_asset::cookie::CookieContext,
group_id:Option<u64>, group_id:Option<u64>,
@ -32,30 +32,30 @@ impl Publisher{
api_internal, api_internal,
} }
} }
pub async fn publish(&self,publish_info:PublishFixRequest)->Result<(),PublishError>{ pub async fn upload(&self,upload_info:UploadFixRequest)->Result<(),UploadError>{
// download the map model version // download the map model version
let model_data=self.roblox_cookie.get_asset(rbx_asset::cookie::GetAssetRequest{ let model_data=self.roblox_cookie.get_asset(rbx_asset::cookie::GetAssetRequest{
asset_id:publish_info.ModelID, asset_id:upload_info.ModelID,
version:Some(publish_info.ModelVersion), version:Some(upload_info.ModelVersion),
}).await.map_err(PublishError::Get)?; }).await.map_err(UploadError::Get)?;
// 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:upload_info.TargetAssetID,
groupId:self.group_id, groupId:self.group_id,
name:None, name:None,
description:None, description:None,
ispublic:None, ispublic:None,
allowComments:None, allowComments:None,
},model_data).await.map_err(PublishError::Upload)?; },model_data).await.map_err(UploadError::Upload)?;
// that's it, the database entry does not need to be changed. // that's it, the database entry does not need to be changed.
// mark submission as uploaded, TargetAssetID is unchanged // mark submission as uploaded, TargetAssetID is unchanged
self.api_internal.action_submission_uploaded(submissions_api::types::ActionSubmissionUploadedRequest{ self.api_internal.action_submission_uploaded(submissions_api::types::ActionSubmissionUploadedRequest{
SubmissionID:publish_info.SubmissionID, SubmissionID:upload_info.SubmissionID,
TargetAssetID:None, TargetAssetID:None,
}).await.map_err(PublishError::ApiActionSubmissionUploaded)?; }).await.map_err(UploadError::ApiActionSubmissionUploaded)?;
Ok(()) Ok(())
} }

@ -1,27 +1,27 @@
use crate::nats_types::PublishNewRequest; use crate::nats_types::UploadNewRequest;
#[allow(dead_code)] #[allow(dead_code)]
#[derive(Debug)] #[derive(Debug)]
pub enum PublishError{ pub enum UploadError{
Get(rbx_asset::cookie::GetError), Get(rbx_asset::cookie::GetError),
Json(serde_json::Error), Json(serde_json::Error),
Create(rbx_asset::cookie::CreateError), Create(rbx_asset::cookie::CreateError),
SystemTime(std::time::SystemTimeError), SystemTime(std::time::SystemTimeError),
ApiActionSubmissionUploaded(submissions_api::Error), ApiActionSubmissionUploaded(submissions_api::Error),
} }
impl std::fmt::Display for PublishError{ impl std::fmt::Display for UploadError{
fn fmt(&self,f:&mut std::fmt::Formatter<'_>)->std::fmt::Result{ fn fmt(&self,f:&mut std::fmt::Formatter<'_>)->std::fmt::Result{
write!(f,"{self:?}") write!(f,"{self:?}")
} }
} }
impl std::error::Error for PublishError{} impl std::error::Error for UploadError{}
pub struct Publisher{ pub struct Uploader{
roblox_cookie:rbx_asset::cookie::CookieContext, roblox_cookie:rbx_asset::cookie::CookieContext,
group_id:Option<u64>, group_id:Option<u64>,
api:submissions_api::internal::Context, api:submissions_api::internal::Context,
} }
impl Publisher{ impl Uploader{
pub const fn new( pub const fn new(
roblox_cookie:rbx_asset::cookie::CookieContext, roblox_cookie:rbx_asset::cookie::CookieContext,
group_id:Option<u64>, group_id:Option<u64>,
@ -33,27 +33,27 @@ impl Publisher{
api, api,
} }
} }
pub async fn publish(&self,publish_info:PublishNewRequest)->Result<(),PublishError>{ pub async fn upload(&self,upload_info:UploadNewRequest)->Result<(),UploadError>{
// download the map model version // download the map model version
let model_data=self.roblox_cookie.get_asset(rbx_asset::cookie::GetAssetRequest{ let model_data=self.roblox_cookie.get_asset(rbx_asset::cookie::GetAssetRequest{
asset_id:publish_info.ModelID, asset_id:upload_info.ModelID,
version:Some(publish_info.ModelVersion), version:Some(upload_info.ModelVersion),
}).await.map_err(PublishError::Get)?; }).await.map_err(UploadError::Get)?;
// upload the map to the strafesnet group // upload the map to the strafesnet group
let upload_response=self.roblox_cookie.create(rbx_asset::cookie::CreateRequest{ let upload_response=self.roblox_cookie.create(rbx_asset::cookie::CreateRequest{
name:publish_info.ModelName.clone(), name:upload_info.ModelName.clone(),
description:"".to_owned(), description:"".to_owned(),
ispublic:false, ispublic:false,
allowComments:false, allowComments:false,
groupId:self.group_id, groupId:self.group_id,
},model_data).await.map_err(PublishError::Create)?; },model_data).await.map_err(UploadError::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
self.api.action_submission_uploaded(submissions_api::types::ActionSubmissionUploadedRequest{ self.api.action_submission_uploaded(submissions_api::types::ActionSubmissionUploadedRequest{
SubmissionID:publish_info.SubmissionID, SubmissionID:upload_info.SubmissionID,
TargetAssetID:Some(upload_response.AssetId), TargetAssetID:Some(upload_response.AssetId),
}).await.map_err(PublishError::ApiActionSubmissionUploaded)?; }).await.map_err(UploadError::ApiActionSubmissionUploaded)?;
Ok(()) Ok(())
} }