Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
fix(email): send Outlook drafts that already hold an attachment (#9284)
teo95d1de8e6585
diff --git a/crates/email/src/domain/mailbox/drafts.rs b/crates/email/src/domain/mailbox/drafts.rsindex 87bab9aef0..02702931a8 100644--- a/crates/email/src/domain/mailbox/drafts.rs+++ b/crates/email/src/domain/mailbox/drafts.rs@@ -372,7 +372,9 @@ impl<R: DraftRepository, G: DraftGateway, M: DraftMaterializer> MailboxDraftServ}if matches.len() == 1 {let found = matches[0];- if found.size != file.size || found.name != file.name || found.inline != file.inline {+ // Graph's size also counts the attachment's other properties, so it+ // exceeds the byte length; only a smaller file means it changed.+ if found.size < file.size || found.name != file.name || found.inline != file.inline {return Err(EmailApiError::Conflict.into());}checkpoint.completed_files += 1;diff --git a/crates/email/src/domain/mailbox/drafts/test.rs b/crates/email/src/domain/mailbox/drafts/test.rsindex 25dff8f576..09026e65f8 100644--- a/crates/email/src/domain/mailbox/drafts/test.rs+++ b/crates/email/src/domain/mailbox/drafts/test.rs@@ -432,6 +432,48 @@ async fn lost_attachment_response_recovers_by_content_id_without_a_second_post()assert_eq!(s.lease.checkpoint.as_ref().unwrap().completed_files, 1);}+#[tokio::test]+async fn resync_keeps_an_uploaded_attachment_whose_provider_size_counts_its_properties() {+ let h = harness(Some(DraftStage::Attachments));+ {+ let mut state = h.0.lock().unwrap();+ state+ .lease+ .checkpoint+ .as_mut()+ .unwrap()+ .prepared+ .files+ .push(DraftFile {+ source: AttachmentSource::Uploaded {+ key: "immutable-key".into(),+ },+ name: "notes.txt".into(),+ content_type: "text/plain".into(),+ content_id: "stable-cid".into(),+ inline: false,+ size: 3,+ sha256: format!("{:x}", Sha256::digest(b"abc")),+ });+ // Graph reports PidTagAttachSize: the content plus the attachment's properties.+ state.attachments.push(DraftAttachment {+ id: ProviderId::new("uploaded-earlier").unwrap(),+ name: "notes.txt".into(),+ size: 3 + 212,+ content_id: Some("stable-cid".into()),+ inline: false,+ });+ }+ let service = service(&h);+ for _ in 0..3 {+ service.execute_once().await.unwrap();+ }+ let state = h.0.lock().unwrap();+ assert!(state.failure.is_none(), "{:?}", state.failure);+ assert_eq!(state.additions, 0);+ assert_eq!(state.submissions, 1);+}+#[tokio::test]async fn forwarded_removal_matches_a_bracketed_provider_content_id() {use crate::domain::models::draft_attachment_manifest::AttachmentRemoval;diff --git a/crates/email_api_client/src/domain/models/draft.rs b/crates/email_api_client/src/domain/models/draft.rsindex ebd0539cf3..cf323f9918 100644--- a/crates/email_api_client/src/domain/models/draft.rs+++ b/crates/email_api_client/src/domain/models/draft.rs@@ -44,7 +44,8 @@ pub struct DraftAttachment {pub id: ProviderId,/// Filename.pub name: String,- /// Decoded byte length.+ /// Provider-reported size. Graph reports `PidTagAttachSize`, which also+ /// counts the attachment's other properties, so it exceeds the byte length.pub size: u64,/// Content-ID retained for reconciliation and inline rendering.pub content_id: Option<String>,