fix
This commit is contained in:
@@ -73,6 +73,7 @@ pub mod schemas {
|
||||
DocumentVersionDetailResponse, DocumentVersionResponse,
|
||||
};
|
||||
pub use crate::documents::correspondents::DocumentCorrespondentResponse;
|
||||
pub use crate::error::ApiErrorResponse;
|
||||
pub use crate::models::ApiCapability;
|
||||
pub use crate::routes::correspondents::{
|
||||
CorrespondentSummary, CorrespondentUsage, CreateCorrespondentRequest,
|
||||
|
||||
@@ -19,6 +19,8 @@ use crate::documents::asset::{
|
||||
asset_object_disposition, DocumentAssetDetailResponse, DocumentAssetResponse,
|
||||
DocumentVersionDetailResponse, DocumentVersionResponse,
|
||||
};
|
||||
#[allow(unused_imports)]
|
||||
use crate::error::ApiErrorResponse;
|
||||
use crate::error::{AppError, AppResult};
|
||||
use crate::http::responders::{accepted_json, created_json, no_content, ok_json, JsonResponse};
|
||||
use crate::models::{Document, DocumentAsset, DocumentAssetObject, DocumentVersion};
|
||||
@@ -189,7 +191,7 @@ pub async fn get_document(
|
||||
(
|
||||
status = 409,
|
||||
description = "Document with identical contents already exists",
|
||||
body = crate::error::ApiErrorResponse
|
||||
body = ApiErrorResponse
|
||||
)
|
||||
),
|
||||
tag = "Documents"
|
||||
@@ -1085,6 +1087,7 @@ pub async fn remove_tag(
|
||||
crate::documents::asset::DocumentAssetDetailResponse,
|
||||
crate::documents::asset::DocumentAssetObjectResponse,
|
||||
crate::documents::correspondents::DocumentCorrespondentResponse,
|
||||
crate::error::ApiErrorResponse,
|
||||
))
|
||||
)]
|
||||
pub struct DocumentsApiDoc;
|
||||
|
||||
@@ -1420,12 +1420,32 @@ impl<'a> DocumentsService<'a> {
|
||||
checksum = %checksum_hex,
|
||||
"upload rejected because document already exists",
|
||||
);
|
||||
|
||||
let mut message = String::from("a document with the same contents already exists");
|
||||
let mut details = json!({
|
||||
"conflict_document_id": document.id,
|
||||
});
|
||||
|
||||
if let Some(deleted_at) = document.deleted_at {
|
||||
message.push_str(
|
||||
". Note: the existing document is currently in the trash.",
|
||||
);
|
||||
if let Some(obj) = details.as_object_mut() {
|
||||
obj.insert(
|
||||
"conflict_document_in_trash".to_string(),
|
||||
Value::Bool(true),
|
||||
);
|
||||
obj.insert(
|
||||
"conflict_document_deleted_at".to_string(),
|
||||
Value::String(to_iso(deleted_at)),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return Err(
|
||||
AppError::conflict("a document with the same contents already exists")
|
||||
AppError::conflict(message)
|
||||
.with_code("duplicate_document")
|
||||
.with_details(json!({
|
||||
"conflict_document_id": document.id,
|
||||
})),
|
||||
.with_details(details),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user