diff --git a/src/modules/cache/model.rs b/src/modules/cache/model.rs index 50420b5..640c618 100644 --- a/src/modules/cache/model.rs +++ b/src/modules/cache/model.rs @@ -19,10 +19,13 @@ use crate::{ #[derive(Clone, Debug, Default, Eq, PartialEq, Deserialize, Serialize, Object)] pub struct Envelope { - /// The unique ID of the message, either IMAP UID or Gmail API MID. + /// The unique identifier of the email message across different systems. /// - /// - For IMAP accounts, this is the UID converted to a string. - /// - For Gmail API accounts, this is the message ID returned by the API. + /// This field maps to the primary message ID used by the respective API or protocol: + /// + /// - **For IMAP accounts:** This is the **UID** (Unique Identifier) converted to a string. + /// - **For Gmail API accounts:** This is the **Message ID (MID)** returned by the Gmail API. + /// - **For Microsoft Graph API accounts:** This is the **ID** property (e.g., the base64-encoded EWS ID) of the message object. pub id: String, /// The ID of the account owning the email. pub account_id: u64, diff --git a/src/modules/cache/vendor/gmail/model/labels.rs b/src/modules/cache/vendor/gmail/model/labels.rs index 74a4c87..77de410 100644 --- a/src/modules/cache/vendor/gmail/model/labels.rs +++ b/src/modules/cache/vendor/gmail/model/labels.rs @@ -2,8 +2,8 @@ // Licensed under RustMailer License Agreement v1.0 // Unauthorized copying, modification, or distribution is prohibited. -use serde::{Deserialize, Serialize}; use crate::modules::cache::vendor::gmail::sync::labels::GmailLabels; +use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Serialize, Deserialize, Default)] pub struct LabelList { @@ -39,10 +39,10 @@ pub struct LabelDetail { pub message_list_visibility: Option, /// Total number of messages with this label #[serde(rename = "messagesTotal")] - pub messages_total: u32, + pub messages_total: Option, /// Number of unread messages with this label #[serde(rename = "messagesUnread")] - pub messages_unread: u32, + pub messages_unread: Option, /// Display name of the label pub name: String, /// Total number of threads with this label @@ -65,8 +65,8 @@ impl From for GmailLabels { id: 0, account_id: 0, name: label.name, - exists: label.messages_total, - unseen: label.messages_unread, + exists: label.messages_total.unwrap_or_default(), + unseen: label.messages_unread.unwrap_or_default(), label_id: label.id, } } diff --git a/src/modules/cache/vendor/gmail/sync/client.rs b/src/modules/cache/vendor/gmail/sync/client.rs index a03720e..a5f5d75 100644 --- a/src/modules/cache/vendor/gmail/sync/client.rs +++ b/src/modules/cache/vendor/gmail/sync/client.rs @@ -43,7 +43,7 @@ impl GmailClient { pub async fn list_labels( account_id: u64, use_proxy: Option, - ) -> RustMailerResult { + ) -> RustMailerResult> { let url = "https://gmail.googleapis.com/gmail/v1/users/me/labels"; let client = HttpClient::new(use_proxy).await?; let access_token = Self::get_access_token(account_id).await?; @@ -53,16 +53,7 @@ impl GmailClient { "Failed to deserialize Gmail API response into LabelList: {:#?}. Possible model mismatch or API change.", e ), ErrorCode::InternalError))?; - Ok(list) - } - - pub async fn list_visible_labels( - account_id: u64, - use_proxy: Option, - ) -> RustMailerResult> { - let all_labels = Self::list_labels(account_id, use_proxy).await?; - let visible_labels: Vec