diff --git a/protos/rustmailer.proto b/protos/rustmailer.proto index 018277b..2f79349 100644 --- a/protos/rustmailer.proto +++ b/protos/rustmailer.proto @@ -533,7 +533,7 @@ message CreateMailboxRequest { /// Only applicable for **Graph API** accounts. /// For IMAP or Gmail API accounts, this field is always `None`. /// The ID can be retrieved via the **`/list-mailboxes?remote=true`** endpoint. - optional uint64 parent_id = 3; + optional string parent_name = 3; // Optional color settings for the label (Gmail API only). // Only applicable to Gmail API accounts. See [`LabelColor`] for the allowed // `text_color` and `background_color` values. diff --git a/src/modules/cache/vendor/outlook/sync/client.rs b/src/modules/cache/vendor/outlook/sync/client.rs index 5532352..bff7c19 100644 --- a/src/modules/cache/vendor/outlook/sync/client.rs +++ b/src/modules/cache/vendor/outlook/sync/client.rs @@ -10,7 +10,6 @@ use crate::{ error::{code::ErrorCode, RustMailerResult}, message::append::ReplyDraft, oauth2::token::OAuth2AccessToken, - utils::mailbox_id, }, raise_error, }; @@ -389,7 +388,7 @@ impl OutlookClient { pub async fn create_folder( account_id: u64, use_proxy: Option, - parent_id: Option, + parent_name: Option, folder_name: &str, ) -> RustMailerResult<()> { let client = HttpClient::new(use_proxy).await?; @@ -397,20 +396,19 @@ impl OutlookClient { let mut url = "https://graph.microsoft.com/v1.0/me/mailFolders".to_string(); let body = json!({ "displayName": folder_name }); - if let Some(parent_id) = parent_id { + if let Some(parent_name) = parent_name { let mailboxes = Self::list_mailfolders(account_id, use_proxy).await?; if let Some(parent) = mailboxes .into_iter() - .find(|m| mailbox_id(account_id, &m.id) == parent_id) + .find(|m| m.display_name == parent_name) { - // parent.id 是 Graph API 的 folder id(字符串),将请求发到父文件夹的 childFolders 端点 url = format!( "https://graph.microsoft.com/v1.0/me/mailFolders/{}/childFolders", parent.id ); } else { return Err(raise_error!( - format!("Parent folder not found: {}", parent_id), + format!("Parent folder not found: {}", parent_name), ErrorCode::InternalError )); } diff --git a/src/modules/grpc/service/mailbox/from.rs b/src/modules/grpc/service/mailbox/from.rs index d905b55..8c25aea 100644 --- a/src/modules/grpc/service/mailbox/from.rs +++ b/src/modules/grpc/service/mailbox/from.rs @@ -95,7 +95,7 @@ impl From for CreateMailboxRequest { fn from(value: rustmailer_grpc::CreateMailboxRequest) -> Self { Self { mailbox_name: value.mailbox_name, - parent_id: value.parent_id, + parent_name: value.parent_name, label_color: value.label_color.map(|c| c.into()), } } diff --git a/src/modules/mailbox/create.rs b/src/modules/mailbox/create.rs index 0159082..acecc0f 100644 --- a/src/modules/mailbox/create.rs +++ b/src/modules/mailbox/create.rs @@ -72,8 +72,8 @@ pub struct CreateMailboxRequest { /// /// Only applicable for **Graph API** accounts. /// For IMAP or Gmail API accounts, this field is always `None`. - /// The ID can be retrieved via the **`/list-mailboxes?remote=true`** endpoint. - pub parent_id: Option, + /// The name can be retrieved via the **`/list-mailboxes?remote=true`** endpoint. + pub parent_name: Option, /// Optional color settings for the label (Gmail API only). /// /// Only applicable to Gmail API accounts. See [`LabelColor`] for the allowed @@ -101,7 +101,7 @@ pub async fn create_mailbox( OutlookClient::create_folder( account_id, account.use_proxy, - request.parent_id, + request.parent_name.clone(), &request.mailbox_name, ) .await