mirror of
https://github.com/rustmailer/rustmailer.git
synced 2026-09-09 08:02:03 +00:00
feat(account): add MailerType to support Gmail API and other mailers
- Introduced `MailerType` enum in Account model - Enables selection of different mailer backends (e.g., Gmail API)
This commit is contained in:
@@ -3,12 +3,12 @@
|
||||
// Unauthorized copying, modification, or distribution is prohibited.
|
||||
|
||||
use crate::{
|
||||
encode_mailbox_name, modules::account::entity::Account,
|
||||
encode_mailbox_name, modules::account::v2::AccountV2,
|
||||
modules::context::executors::RUST_MAIL_CONTEXT, modules::error::RustMailerResult,
|
||||
};
|
||||
|
||||
pub async fn create_mailbox(account_id: u64, mailbox_name: &str) -> RustMailerResult<()> {
|
||||
Account::check_account_active(account_id).await?;
|
||||
AccountV2::check_account_active(account_id).await?;
|
||||
let executor = RUST_MAIL_CONTEXT.imap(account_id).await?;
|
||||
executor
|
||||
.create_mailbox(encode_mailbox_name!(mailbox_name).as_str())
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
// Unauthorized copying, modification, or distribution is prohibited.
|
||||
|
||||
use crate::{encode_mailbox_name, modules::{
|
||||
account::entity::Account, context::executors::RUST_MAIL_CONTEXT, error::RustMailerResult,
|
||||
account::v2::AccountV2, context::executors::RUST_MAIL_CONTEXT, error::RustMailerResult,
|
||||
}};
|
||||
|
||||
pub async fn delete_mailbox(account_id: u64, mailbox_name: &str) -> RustMailerResult<()> {
|
||||
Account::check_account_active(account_id).await?;
|
||||
AccountV2::check_account_active(account_id).await?;
|
||||
let executor = RUST_MAIL_CONTEXT.imap(account_id).await?;
|
||||
executor.delete_mailbox(encode_mailbox_name!(mailbox_name).as_str()).await
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// Licensed under RustMailer License Agreement v1.0
|
||||
// Unauthorized copying, modification, or distribution is prohibited.
|
||||
|
||||
use crate::modules::account::entity::Account;
|
||||
use crate::modules::account::v2::AccountV2;
|
||||
use crate::modules::cache::imap::mailbox::{Attribute, AttributeEnum, MailBox};
|
||||
use crate::modules::context::executors::RUST_MAIL_CONTEXT;
|
||||
use crate::modules::error::code::ErrorCode;
|
||||
@@ -15,8 +15,8 @@ pub async fn get_account_mailboxes(
|
||||
account_id: u64,
|
||||
remote: bool,
|
||||
) -> RustMailerResult<Vec<MailBox>> {
|
||||
let account = Account::check_account_active(account_id).await?;
|
||||
let remote = remote || account.minimal_sync;
|
||||
let account = AccountV2::check_account_active(account_id).await?;
|
||||
let remote = remote || account.minimal_sync();
|
||||
if remote {
|
||||
request_imap_all_mailbox_list(account_id).await
|
||||
} else {
|
||||
@@ -25,7 +25,7 @@ pub async fn get_account_mailboxes(
|
||||
}
|
||||
|
||||
pub async fn list_subscribed_mailboxes(account_id: u64) -> RustMailerResult<Vec<MailBox>> {
|
||||
Account::check_account_active(account_id).await?;
|
||||
AccountV2::check_account_active(account_id).await?;
|
||||
request_imap_subscribed_mailbox_list(account_id).await
|
||||
}
|
||||
|
||||
|
||||
@@ -2,9 +2,12 @@
|
||||
// Licensed under RustMailer License Agreement v1.0
|
||||
// Unauthorized copying, modification, or distribution is prohibited.
|
||||
|
||||
use crate::{encode_mailbox_name, modules::{
|
||||
account::entity::Account, context::executors::RUST_MAIL_CONTEXT, error::RustMailerResult,
|
||||
}};
|
||||
use crate::{
|
||||
encode_mailbox_name,
|
||||
modules::{
|
||||
account::v2::AccountV2, context::executors::RUST_MAIL_CONTEXT, error::RustMailerResult,
|
||||
},
|
||||
};
|
||||
use poem_openapi::Object;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
@@ -22,9 +25,12 @@ pub async fn rename_mailbox(
|
||||
account_id: u64,
|
||||
payload: MailboxRenameRequest,
|
||||
) -> RustMailerResult<()> {
|
||||
Account::check_account_active(account_id).await?;
|
||||
AccountV2::check_account_active(account_id).await?;
|
||||
let executor = RUST_MAIL_CONTEXT.imap(account_id).await?;
|
||||
executor
|
||||
.rename_mailbox(encode_mailbox_name!(&payload.current_name).as_str(), encode_mailbox_name!(&payload.new_name).as_str())
|
||||
.rename_mailbox(
|
||||
encode_mailbox_name!(&payload.current_name).as_str(),
|
||||
encode_mailbox_name!(&payload.new_name).as_str(),
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
@@ -5,12 +5,12 @@
|
||||
use crate::{
|
||||
encode_mailbox_name,
|
||||
modules::{
|
||||
account::entity::Account, context::executors::RUST_MAIL_CONTEXT, error::RustMailerResult,
|
||||
account::v2::AccountV2, context::executors::RUST_MAIL_CONTEXT, error::RustMailerResult,
|
||||
},
|
||||
};
|
||||
|
||||
pub async fn subscribe_mailbox(account_id: u64, mailbox_name: &str) -> RustMailerResult<()> {
|
||||
Account::check_account_active(account_id).await?;
|
||||
AccountV2::check_account_active(account_id).await?;
|
||||
let executor = RUST_MAIL_CONTEXT.imap(account_id).await?;
|
||||
executor
|
||||
.subscribe_mailbox(encode_mailbox_name!(mailbox_name).as_str())
|
||||
@@ -18,7 +18,7 @@ pub async fn subscribe_mailbox(account_id: u64, mailbox_name: &str) -> RustMaile
|
||||
}
|
||||
|
||||
pub async fn unsubscribe_mailbox(account_id: u64, mailbox_name: &str) -> RustMailerResult<()> {
|
||||
Account::check_account_active(account_id).await?;
|
||||
AccountV2::check_account_active(account_id).await?;
|
||||
let executor = RUST_MAIL_CONTEXT.imap(account_id).await?;
|
||||
executor
|
||||
.unsubscribe_mailbox(encode_mailbox_name!(mailbox_name).as_str())
|
||||
|
||||
Reference in New Issue
Block a user