mirror of
https://github.com/rustmailer/bichon.git
synced 2026-08-03 07:48:34 +02:00
feat(search): add advanced attachment filters for extension, category and mime type
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
use std::collections::HashSet;
|
||||
|
||||
use poem_openapi::Object;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, Default, Eq, PartialEq, Deserialize, Serialize, Object)]
|
||||
pub struct AttachmentMetadata {
|
||||
/// A collection of unique file extensions found in attachments.
|
||||
/// Example: ["pdf", "docx", "png"]
|
||||
pub extensions: HashSet<String>,
|
||||
|
||||
/// A collection of high-level attachment categories.
|
||||
/// Example: ["document", "image", "archive"]
|
||||
pub categories: HashSet<String>,
|
||||
|
||||
/// A collection of unique MIME types (Content-Type) for the attachments.
|
||||
/// Example: ["application/pdf", "image/jpeg"]
|
||||
pub content_types: HashSet<String>,
|
||||
}
|
||||
@@ -51,7 +51,7 @@ impl AttachmentInfo {
|
||||
std::path::Path::new(&self.filename)
|
||||
.extension()
|
||||
.and_then(|ext| ext.to_str())
|
||||
.map(|ext| ext.to_lowercase())
|
||||
.map(|ext| ext.to_ascii_lowercase())
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
pub mod append;
|
||||
pub mod attachment;
|
||||
pub mod contacts;
|
||||
pub mod content;
|
||||
pub mod delete;
|
||||
|
||||
@@ -50,6 +50,9 @@ pub struct SearchFilter {
|
||||
pub has_attachment: Option<bool>,
|
||||
pub attachment_name: Option<String>,
|
||||
pub tags: Option<HashSet<String>>,
|
||||
pub attachment_extension: Option<String>,
|
||||
pub attachment_category: Option<String>,
|
||||
pub attachment_content_type: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Default, Eq, PartialEq, Serialize, Deserialize, Enum)]
|
||||
|
||||
Reference in New Issue
Block a user