Add Graph API compatibility for delete-mailbox and update-mailbox operations

This commit is contained in:
rustmailer
2025-11-06 23:12:44 +08:00
parent c50bd26cd9
commit 566beabb7a
5 changed files with 96 additions and 11 deletions
+5 -1
View File
@@ -181,11 +181,15 @@ impl GmailClient {
let mut body = json!({
"id": label_id,
"name": request.new_name,
"messageListVisibility": "show",
"labelListVisibility": "labelShow",
"type": "user"
});
if let Some(new_name) = &request.new_name {
body["name"] = json!(new_name);
}
if let Some(color) = &request.label_color {
body["color"] = json!({
"textColor": color.text_color,
+27
View File
@@ -417,4 +417,31 @@ impl OutlookClient {
client.post(&url, &access_token, Some(&body), false).await?;
Ok(())
}
pub async fn delete_folder(
account_id: u64,
use_proxy: Option<u64>,
folder_id: &str,
) -> RustMailerResult<()> {
let url = format!("https://graph.microsoft.com/v1.0/me/mailFolders/{folder_id}");
let client = HttpClient::new(use_proxy).await?;
let access_token = Self::get_access_token(account_id).await?;
client.delete(url.as_str(), &access_token).await
}
pub async fn rename_folder(
account_id: u64,
use_proxy: Option<u64>,
folder_id: &str,
new_name: &str,
) -> RustMailerResult<()> {
let url = format!("https://graph.microsoft.com/v1.0/me/mailFolders/{folder_id}");
let client = HttpClient::new(use_proxy).await?;
let access_token = Self::get_access_token(account_id).await?;
let data = json!({
"displayName": new_name
});
client.patch(url.as_str(), &access_token, &data).await?;
Ok(())
}
}