mirror of
https://github.com/rustmailer/bichon.git
synced 2026-08-03 07:48:34 +02:00
feat: support export account emails to a single mbox file
This commit is contained in:
@@ -25,8 +25,10 @@ use bichon_core::account::payload::{
|
||||
filter_accessible_accounts, AccountCreateRequest, AccountUpdateRequest, MinimalAccount,
|
||||
};
|
||||
use bichon_core::account::state::DownloadState;
|
||||
use bichon_core::account::stats::AccountStats;
|
||||
use bichon_core::account::view::AccountResp;
|
||||
use bichon_core::common::paginated::{paginate_vec, DataPage};
|
||||
use bichon_core::store::tantivy::envelope::ENVELOPE_MANAGER;
|
||||
use bichon_core::users::permissions::Permission;
|
||||
use bichon_core::users::UserModel;
|
||||
use poem_openapi::param::{Path, Query};
|
||||
@@ -182,11 +184,11 @@ impl AccountApi {
|
||||
|
||||
/// Get the running state of an account
|
||||
#[oai(
|
||||
path = "/account-state/:account_id",
|
||||
path = "/accounts/:account_id/download-stats",
|
||||
method = "get",
|
||||
operation_id = "account_state"
|
||||
operation_id = "accounts_download_state"
|
||||
)]
|
||||
async fn account_state(
|
||||
async fn accounts_download_state(
|
||||
&self,
|
||||
/// The account ID to check state for
|
||||
account_id: Path<u64>,
|
||||
@@ -202,6 +204,27 @@ impl AccountApi {
|
||||
Ok(Json(state))
|
||||
}
|
||||
|
||||
/// Get the stats of an account
|
||||
#[oai(
|
||||
path = "/accounts/:account_id/stats",
|
||||
method = "get",
|
||||
operation_id = "accounts_stats"
|
||||
)]
|
||||
async fn accounts_stats(
|
||||
&self,
|
||||
/// The account ID to check state for
|
||||
account_id: Path<u64>,
|
||||
context: WrappedContext,
|
||||
) -> ApiResult<Json<AccountStats>> {
|
||||
let account_id = account_id.0;
|
||||
AccountModel::check_account_exists(account_id).await?;
|
||||
context
|
||||
.require_permission(Some(account_id), Permission::ACCOUNT_READ_DETAILS)
|
||||
.await?;
|
||||
let state = ENVELOPE_MANAGER.get_account_stats(account_id).await?;
|
||||
Ok(Json(state))
|
||||
}
|
||||
|
||||
/// Get a minimal list of active accounts for use in selectors when creating account-related resources
|
||||
///
|
||||
/// This endpoint provides a lightweight list of accounts containing only essential information (id and name).
|
||||
|
||||
Reference in New Issue
Block a user