This commit is contained in:
rustmailer
2026-05-02 23:53:04 +08:00
parent 2d29a8111b
commit e2fb0ee39e
7 changed files with 17 additions and 11 deletions
+1 -1
View File
@@ -48,6 +48,7 @@ async-imap = { git = "https://github.com/rustmailer/async-imap.git", branch = "m
"runtime-tokio",
"compress",
] }
tantivy = { version = "0.26.0", features = ["zstd-compression"] }
webpki-roots.workspace = true
rustls.workspace = true
rustls-pki-types.workspace = true
@@ -65,6 +66,5 @@ mail-send.workspace = true
blake3.workspace = true
uuid.workspace = true
fjall.workspace = true
tantivy.workspace = true
tracing-log.workspace = true
tokio-util.workspace = true
+12 -1
View File
@@ -16,7 +16,12 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
use tantivy::IndexWriter;
use tantivy::{schema::Facet, IndexWriter};
use crate::{
error::{code::ErrorCode, BichonResult},
raise_error,
};
pub mod attachment;
pub mod envelope;
@@ -66,3 +71,9 @@ pub fn fatal_commit(writer: &mut IndexWriter) {
}
}
}
pub fn validate_facet(tag: &str) -> BichonResult<()> {
Facet::from_text(tag)
.map(|_| ())
.map_err(|e| raise_error!(format!("{:#?}", e), ErrorCode::InvalidParameter))
}
-1
View File
@@ -19,7 +19,6 @@ poem-openapi = { version = "5.1.16", features = [
] }
rust-embed = "8.11.0"
email_address.workspace = true
tantivy.workspace = true
serde.workspace = true
serde_json.workspace = true
governor.workspace = true
+2 -3
View File
@@ -29,12 +29,12 @@ use bichon_core::message::tags::TagsRequest;
use bichon_core::raise_error;
use bichon_core::store::tantivy::attachment::ATTACHMENT_MANAGER;
use bichon_core::store::tantivy::model::AttachmentModel;
use bichon_core::store::tantivy::validate_facet;
use bichon_core::users::permissions::Permission;
use poem_openapi::param::Path;
use poem_openapi::payload::Json;
use poem_openapi::OpenApi;
use std::collections::HashSet;
use tantivy::schema::Facet;
pub struct AttachmentApi;
@@ -133,8 +133,7 @@ impl AttachmentApi {
) -> ApiResult<()> {
let req = req.0;
for tag in &req.tags {
Facet::from_text(tag)
.map_err(|e| raise_error!(format!("{:#?}", e), ErrorCode::InvalidParameter))?;
validate_facet(tag)?;
}
for account_id in req.updates.keys() {
+2 -3
View File
@@ -38,6 +38,7 @@ use bichon_core::raise_error;
use bichon_core::store::envelope::Envelope;
use bichon_core::store::storage::get_reader;
use bichon_core::store::tantivy::envelope::ENVELOPE_MANAGER;
use bichon_core::store::tantivy::validate_facet;
use bichon_core::users::permissions::Permission;
use poem::Body;
use poem_openapi::param::{Path, Query};
@@ -45,7 +46,6 @@ use poem_openapi::payload::{Attachment, AttachmentType, Json};
use poem_openapi::OpenApi;
use std::collections::HashMap;
use std::collections::HashSet;
use tantivy::schema::Facet;
pub struct MessageApi;
@@ -350,8 +350,7 @@ impl MessageApi {
) -> ApiResult<()> {
let req = req.0;
for tag in &req.tags {
Facet::from_text(tag)
.map_err(|e| raise_error!(format!("{:#?}", e), ErrorCode::InvalidParameter))?;
validate_facet(tag)?;
}
for account_id in req.updates.keys() {