feat(chat): colle les fichiers du presse-papiers via Ctrl+V dans le composer (#181)

This commit is contained in:
2026-08-11 15:57:30 +02:00
parent ce2640c9af
commit 419987d890
4 changed files with 296 additions and 3 deletions

View File

@ -110,6 +110,7 @@ impl ImportChatAttachments {
.await?
}
ImportChatAttachmentSource::Bytes { bytes, .. } => {
validate_attachment_size(bytes.len() as u64)?;
self.store
.import_from_bytes(
&input.project.root,
@ -174,6 +175,20 @@ fn validate_attachment_filename(filename: &str) -> Result<(), AppError> {
Ok(())
}
fn validate_attachment_size(size_bytes: u64) -> Result<(), AppError> {
if size_bytes == 0 {
return Err(AppError::Invalid(
"chat attachment must not be empty".to_owned(),
));
}
if size_bytes > CHAT_ATTACHMENT_MAX_BYTES {
return Err(AppError::Invalid(format!(
"chat attachment exceeds {CHAT_ATTACHMENT_MAX_BYTES} bytes"
)));
}
Ok(())
}
fn sanitize_mime(raw: Option<&str>, filename: &str) -> Result<String, AppError> {
let mime = raw
.map(str::trim)