feat(chat): colle les fichiers du presse-papiers via Ctrl+V dans le composer (#181)
This commit is contained in:
@ -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)
|
||||
|
||||
Reference in New Issue
Block a user