feat(search): add advanced attachment filters for extension, category and mime type

This commit is contained in:
rustmailer
2026-03-19 20:23:20 +08:00
parent 884fdeba10
commit c19f3977ba
31 changed files with 466 additions and 40 deletions
+19
View File
@@ -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>,
}
+1 -1
View File
@@ -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()
}
+1
View File
@@ -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;
+3
View File
@@ -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)]