mirror of
https://github.com/rustmailer/rustmailer.git
synced 2026-09-09 00:01:34 +00:00
refactor(gmail): update account sync logic and related files
This commit is contained in:
@@ -51,7 +51,7 @@ pub struct AppendReplyToDraftRequest {
|
||||
|
||||
impl AppendReplyToDraftRequest {
|
||||
pub async fn append_reply_to_draft(&self, account_id: u64) -> RustMailerResult<()> {
|
||||
let account = AccountV2::check_account_active(account_id).await?;
|
||||
let account = AccountV2::check_account_active(account_id, false).await?;
|
||||
let envelope = EmailHandler::get_envelope(&account, &self.mailbox_name, self.uid).await?;
|
||||
let from = Address::new_address(
|
||||
account.name.as_ref().map(|n| Cow::Owned(n.to_string())),
|
||||
|
||||
@@ -59,7 +59,7 @@ pub async fn retrieve_email_attachment(
|
||||
account_id: u64,
|
||||
request: AttachmentRequest,
|
||||
) -> RustMailerResult<cacache::Reader> {
|
||||
AccountV2::check_account_active(account_id).await?;
|
||||
AccountV2::check_account_active(account_id, false).await?;
|
||||
|
||||
if request.attachment.size >= MAX_ATTACHMENT_SIZE {
|
||||
return Err(raise_error!(
|
||||
|
||||
@@ -283,7 +283,7 @@ pub async fn retrieve_email_content(
|
||||
request: MessageContentRequest,
|
||||
skip_cache: bool,
|
||||
) -> RustMailerResult<MessageContent> {
|
||||
AccountV2::check_account_active(account_id).await?;
|
||||
AccountV2::check_account_active(account_id, false).await?;
|
||||
|
||||
let mut plain: Option<PlainText> = None;
|
||||
let mut html: Option<String> = None;
|
||||
|
||||
@@ -33,7 +33,7 @@ pub async fn copy_mailbox_messages(
|
||||
payload: &MailboxTransferRequest,
|
||||
) -> RustMailerResult<()> {
|
||||
// Ensure the account exists before proceeding
|
||||
AccountV2::check_account_active(account_id).await?;
|
||||
AccountV2::check_account_active(account_id, false).await?;
|
||||
|
||||
// Generate a set of UIDs from the payload
|
||||
let uid_set = generate_uid_set(payload.uids.clone());
|
||||
|
||||
@@ -25,7 +25,7 @@ pub async fn move_to_trash_or_delete_messages_directly(
|
||||
account_id: u64,
|
||||
request: &MessageDeleteRequest,
|
||||
) -> RustMailerResult<()> {
|
||||
AccountV2::check_account_active(account_id).await?;
|
||||
AccountV2::check_account_active(account_id, false).await?;
|
||||
let uid_set = generate_uid_set(request.uids.clone());
|
||||
let executor = RUST_MAIL_CONTEXT.imap(account_id).await?;
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ impl FlagAction {
|
||||
}
|
||||
|
||||
pub async fn modify_flags(account_id: u64, request: FlagMessageRequest) -> RustMailerResult<()> {
|
||||
AccountV2::check_account_active(account_id).await?;
|
||||
AccountV2::check_account_active(account_id, true).await?;
|
||||
request.validate()?;
|
||||
|
||||
let executor = RUST_MAIL_CONTEXT.imap(account_id).await?;
|
||||
|
||||
@@ -35,7 +35,7 @@ pub async fn retrieve_full_email(
|
||||
mailbox: String,
|
||||
uid: u32,
|
||||
) -> RustMailerResult<cacache::Reader> {
|
||||
AccountV2::check_account_active(account_id).await?;
|
||||
AccountV2::check_account_active(account_id, false).await?;
|
||||
let meta = get_minimal_meta(account_id, &mailbox, uid).await?;
|
||||
if meta.size > MAX_EMAIL_TOTAL_SIZE {
|
||||
return Err(raise_error!(format!(
|
||||
|
||||
@@ -24,7 +24,7 @@ pub async fn list_messages_in_mailbox(
|
||||
remote: bool,
|
||||
desc: bool,
|
||||
) -> RustMailerResult<DataPage<EmailEnvelopeV3>> {
|
||||
let account = AccountV2::check_account_active(account_id).await?;
|
||||
let account = AccountV2::check_account_active(account_id, false).await?;
|
||||
validate_pagination_params(page, page_size)?;
|
||||
let remote = remote || account.minimal_sync();
|
||||
|
||||
@@ -125,7 +125,7 @@ pub async fn list_threads_in_mailbox(
|
||||
page_size: u64,
|
||||
desc: bool,
|
||||
) -> RustMailerResult<DataPage<EmailEnvelopeV3>> {
|
||||
let account = AccountV2::check_account_active(account_id).await?;
|
||||
let account = AccountV2::check_account_active(account_id, false).await?;
|
||||
validate_pagination_params(page, page_size)?;
|
||||
if account.minimal_sync() {
|
||||
return Err(raise_error!(
|
||||
@@ -160,7 +160,7 @@ pub async fn get_thread_messages(
|
||||
mailbox_name: &str,
|
||||
thread_id: u64,
|
||||
) -> RustMailerResult<Vec<EmailEnvelopeV3>> {
|
||||
let account = AccountV2::check_account_active(account_id).await?;
|
||||
let account = AccountV2::check_account_active(account_id, false).await?;
|
||||
if account.minimal_sync() {
|
||||
return Err(raise_error!(
|
||||
format!(
|
||||
|
||||
@@ -14,7 +14,7 @@ pub async fn move_mailbox_messages(
|
||||
payload: &MailboxTransferRequest,
|
||||
) -> RustMailerResult<()> {
|
||||
// Ensure the account exists before proceeding
|
||||
AccountV2::check_account_active(account_id).await?;
|
||||
AccountV2::check_account_active(account_id, false).await?;
|
||||
|
||||
// Generate a set of UIDs from the payload
|
||||
let uid_set = generate_uid_set(payload.uids.clone());
|
||||
|
||||
@@ -437,7 +437,7 @@ impl MessageSearchRequest {
|
||||
page_size: u64,
|
||||
desc: bool,
|
||||
) -> RustMailerResult<DataPage<EmailEnvelopeV3>> {
|
||||
let account = AccountV2::check_account_active(account_id).await?;
|
||||
let account = AccountV2::check_account_active(account_id, false).await?;
|
||||
self.search_remote(&account, page, page_size, desc).await
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user