refactor!: replace Tantivy search engine with DuckDB

This commit is contained in:
rustmailer
2026-03-03 12:30:26 +08:00
parent ef4ab3496e
commit d2936ed4a7
52 changed files with 3594 additions and 1821 deletions
+1 -1
View File
@@ -58,7 +58,7 @@ impl AccountApi {
context
.require_permission(Some(account_id), Permission::ACCOUNT_READ_DETAILS)
.await?;
Ok(Json(AccountModel::get(account_id).await?))
Ok(Json(AccountModel::async_get(account_id).await?))
}
/// Delete an account by ID - WARNING: This permanently removes the account and all associated resources
+11 -11
View File
@@ -34,6 +34,7 @@ use crate::modules::rest::response::DataPage;
use crate::modules::rest::ApiResult;
use crate::modules::rest::ErrorCode;
use crate::modules::users::permissions::Permission;
use crate::modules::utils::validate_tag;
use crate::raise_error;
use poem::Body;
use poem_openapi::param::{Path, Query};
@@ -41,7 +42,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;
@@ -147,7 +147,7 @@ impl MessageApi {
/// Fetches the content of a specific email.
#[oai(
path = "/message-content/:account_id/:message_id",
path = "/message-content/:account_id/:envelope_id",
method = "get",
operation_id = "fetch_message_content"
)]
@@ -156,7 +156,7 @@ impl MessageApi {
/// The ID of the account.
account_id: Path<u64>,
/// The ID of the message to fetch.
message_id: Path<u64>,
envelope_id: Path<u64>,
context: ClientContext,
) -> ApiResult<Json<FullMessageContent>> {
let account_id = account_id.0;
@@ -164,13 +164,13 @@ impl MessageApi {
.require_permission(Some(account_id), Permission::DATA_READ)
.await?;
Ok(Json(
retrieve_email_content(account_id, message_id.0).await?,
retrieve_email_content(account_id, envelope_id.0).await?,
))
}
/// Retrieves the envelope (metadata) of a specific message.
#[oai(
path = "/envelope/:account_id/:message_id",
path = "/envelope/:account_id/:envelope_id",
method = "get",
operation_id = "get_envelope"
)]
@@ -179,7 +179,7 @@ impl MessageApi {
/// The ID of the account.
account_id: Path<u64>,
/// The ID of the message.
message_id: Path<u64>,
envelope_id: Path<u64>,
context: ClientContext,
) -> ApiResult<Json<Envelope>> {
let account_id = account_id.0;
@@ -187,13 +187,13 @@ impl MessageApi {
.require_permission(Some(account_id), Permission::DATA_READ)
.await?;
let envelope = ENVELOPE_INDEX_MANAGER
.get_envelope_by_id(account_id, message_id.0)
.get_envelope_by_id(account_id, envelope_id.0)
.await?
.ok_or_else(|| {
raise_error!(
format!(
"Envelope not found: account_id={} message_id={}",
account_id, message_id.0
"Envelope not found: account_id={} envelope_id={}",
account_id, envelope_id.0
),
ErrorCode::ResourceNotFound
)
@@ -308,8 +308,8 @@ 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_tag(tag)
.map_err(|e| raise_error!(format!("{}", e), ErrorCode::InvalidParameter))?;
}
for account_id in req.updates.keys() {