refactor(api-server): narrow puzzle state surface
This commit is contained in:
@@ -394,9 +394,13 @@ pub async fn confirm_asset_object(
|
||||
let result = state
|
||||
.spacetime_client()
|
||||
.confirm_asset_object(
|
||||
build_confirm_asset_object_upsert_input(oss_client, payload)
|
||||
.await
|
||||
.map_err(map_confirm_asset_object_prepare_error)?,
|
||||
build_confirm_asset_object_upsert_input(
|
||||
oss_client,
|
||||
payload,
|
||||
authenticated.claims().user_id(),
|
||||
)
|
||||
.await
|
||||
.map_err(map_confirm_asset_object_prepare_error)?,
|
||||
)
|
||||
.await
|
||||
.map_err(map_confirm_asset_object_error)?;
|
||||
@@ -592,6 +596,7 @@ fn supported_asset_history_kind_message() -> String {
|
||||
async fn build_confirm_asset_object_upsert_input(
|
||||
oss_client: &platform_oss::OssClient,
|
||||
payload: ConfirmAssetObjectRequest,
|
||||
authenticated_owner_user_id: &str,
|
||||
) -> Result<module_assets::AssetObjectUpsertInput, ConfirmAssetObjectPrepareError> {
|
||||
let configured_bucket = oss_client.config_bucket().to_string();
|
||||
let resolved_bucket = payload
|
||||
@@ -629,6 +634,14 @@ async fn build_confirm_asset_object_upsert_input(
|
||||
{
|
||||
return Err(ConfirmAssetObjectPrepareError::ContentLengthMismatch);
|
||||
}
|
||||
let owner_user_id = normalize_optional_value(payload.owner_user_id).or_else(|| {
|
||||
let owner = authenticated_owner_user_id.trim();
|
||||
if owner.is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some(owner.to_string())
|
||||
}
|
||||
});
|
||||
|
||||
let now_micros = current_utc_micros();
|
||||
build_asset_object_upsert_input(
|
||||
@@ -645,7 +658,7 @@ async fn build_confirm_asset_object_upsert_input(
|
||||
normalize_optional_value(payload.content_hash),
|
||||
payload.asset_kind,
|
||||
payload.source_job_id,
|
||||
payload.owner_user_id,
|
||||
owner_user_id,
|
||||
payload.profile_id,
|
||||
payload.entity_id,
|
||||
now_micros,
|
||||
|
||||
Reference in New Issue
Block a user