Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

feat(email-service): Make draft attachments visible (#891)

Evan Hutnik1f35a40bdd24
diff --git a/rust/cloud-storage/email_db_client/.sqlx/query-03f7e77f68c35c9056be61123b68b138e979311d3f857705f7a5fa58e78009ba.json b/rust/cloud-storage/email_db_client/.sqlx/query-1490ec3dcbefe6dff27992f93481ee30fef91724dadb7b7c1e461d8286235f60.json
similarity index 62%
rename from rust/cloud-storage/email_db_client/.sqlx/query-03f7e77f68c35c9056be61123b68b138e979311d3f857705f7a5fa58e78009ba.json
rename to rust/cloud-storage/email_db_client/.sqlx/query-1490ec3dcbefe6dff27992f93481ee30fef91724dadb7b7c1e461d8286235f60.json
index 7021b5cce8..70047a0c81 100644
--- a/rust/cloud-storage/email_db_client/.sqlx/query-03f7e77f68c35c9056be61123b68b138e979311d3f857705f7a5fa58e78009ba.json
+++ b/rust/cloud-storage/email_db_client/.sqlx/query-1490ec3dcbefe6dff27992f93481ee30fef91724dadb7b7c1e461d8286235f60.json
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
- "query": "\n INSERT INTO email_messages (\n id, provider_id, link_id, global_id, thread_id, provider_thread_id, replying_to_id, provider_history_id, internal_date_ts,\n snippet, size_estimate, subject, from_name, from_contact_id, sent_at, has_attachments, is_read,\n is_starred, is_sent, is_draft, body_text, body_html_sanitized, headers_jsonb\n )\n VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23)\n ON CONFLICT (link_id, provider_id) WHERE provider_id IS NOT NULL DO UPDATE SET\n global_id = EXCLUDED.global_id,\n provider_history_id = EXCLUDED.provider_history_id,\n provider_thread_id = EXCLUDED.provider_thread_id,\n replying_to_id = EXCLUDED.replying_to_id,\n from_name = EXCLUDED.from_name,\n internal_date_ts = EXCLUDED.internal_date_ts,\n snippet = EXCLUDED.snippet,\n size_estimate = EXCLUDED.size_estimate,\n subject = EXCLUDED.subject,\n sent_at = EXCLUDED.sent_at,\n is_read = EXCLUDED.is_read,\n is_starred = EXCLUDED.is_starred,\n is_sent = EXCLUDED.is_sent,\n is_draft = EXCLUDED.is_draft,\n headers_jsonb = EXCLUDED.headers_jsonb,\n body_text = EXCLUDED.body_text,\n body_html_sanitized = EXCLUDED.body_html_sanitized,\n updated_at = NOW()\n RETURNING id\n ",
+ "query": "\n INSERT INTO email_messages (\n id, provider_id, link_id, global_id, thread_id, provider_thread_id, replying_to_id, provider_history_id, internal_date_ts,\n snippet, size_estimate, subject, from_name, from_contact_id, sent_at, has_attachments, is_read,\n is_starred, is_sent, is_draft, body_text, body_html_sanitized, headers_jsonb\n )\n VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23)\n ON CONFLICT (link_id, provider_id) WHERE provider_id IS NOT NULL DO UPDATE SET\n global_id = EXCLUDED.global_id,\n provider_history_id = EXCLUDED.provider_history_id,\n provider_thread_id = EXCLUDED.provider_thread_id,\n replying_to_id = EXCLUDED.replying_to_id,\n from_name = EXCLUDED.from_name,\n from_contact_id = EXCLUDED.from_contact_id,\n internal_date_ts = EXCLUDED.internal_date_ts,\n snippet = EXCLUDED.snippet,\n size_estimate = EXCLUDED.size_estimate,\n subject = EXCLUDED.subject,\n sent_at = EXCLUDED.sent_at,\n has_attachments = EXCLUDED.has_attachments,\n is_read = EXCLUDED.is_read,\n is_starred = EXCLUDED.is_starred,\n is_sent = EXCLUDED.is_sent,\n is_draft = EXCLUDED.is_draft,\n headers_jsonb = EXCLUDED.headers_jsonb,\n body_text = EXCLUDED.body_text,\n body_html_sanitized = EXCLUDED.body_html_sanitized,\n updated_at = NOW()\n RETURNING id\n ",
"describe": {
"columns": [
{
@@ -40,5 +40,5 @@
false
]
},
- "hash": "03f7e77f68c35c9056be61123b68b138e979311d3f857705f7a5fa58e78009ba"
+ "hash": "1490ec3dcbefe6dff27992f93481ee30fef91724dadb7b7c1e461d8286235f60"
}
diff --git a/rust/cloud-storage/email_db_client/.sqlx/query-3fbfbcc254100b7a9f9fe10f2bccf7c46c18332593a1dd14ad15b5ee30765bab.json b/rust/cloud-storage/email_db_client/.sqlx/query-3fbfbcc254100b7a9f9fe10f2bccf7c46c18332593a1dd14ad15b5ee30765bab.json
new file mode 100644
index 0000000000..93fadf45b9
--- /dev/null
+++ b/rust/cloud-storage/email_db_client/.sqlx/query-3fbfbcc254100b7a9f9fe10f2bccf7c46c18332593a1dd14ad15b5ee30765bab.json
@@ -0,0 +1,58 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n SELECT id, draft_id, file_name, content_type, sha, size, s3_key\n FROM email_attachments_drafts\n WHERE draft_id = $1\n ORDER BY file_name ASC\n ",
+ "describe": {
+ "columns": [
+ {
+ "ordinal": 0,
+ "name": "id",
+ "type_info": "Uuid"
+ },
+ {
+ "ordinal": 1,
+ "name": "draft_id",
+ "type_info": "Uuid"
+ },
+ {
+ "ordinal": 2,
+ "name": "file_name",
+ "type_info": "Text"
+ },
+ {
+ "ordinal": 3,
+ "name": "content_type",
+ "type_info": "Text"
+ },
+ {
+ "ordinal": 4,
+ "name": "sha",
+ "type_info": "Text"
+ },
+ {
+ "ordinal": 5,
+ "name": "size",
+ "type_info": "Int4"
+ },
+ {
+ "ordinal": 6,
+ "name": "s3_key",
+ "type_info": "Text"
+ }
+ ],
+ "parameters": {
+ "Left": [
+ "Uuid"
+ ]
+ },
+ "nullable": [
+ false,
+ false,
+ false,
+ false,
+ false,
+ false,
+ false
+ ]
+ },
+ "hash": "3fbfbcc254100b7a9f9fe10f2bccf7c46c18332593a1dd14ad15b5ee30765bab"
+}
diff --git a/rust/cloud-storage/email_db_client/fixtures/fetch_db_draft_attachments.sql b/rust/cloud-storage/email_db_client/fixtures/fetch_db_draft_attachments.sql
new file mode 100644
index 0000000000..739e554e47
--- /dev/null
+++ b/rust/cloud-storage/email_db_client/fixtures/fetch_db_draft_attachments.sql
@@ -0,0 +1,92 @@
+-- SQL fixture for fetch_db_draft_attachments tests
+-- Tests fetching draft attachments by draft_id, ordered by file_name
+
+------------------------------------------------------------
+-- User Link
+------------------------------------------------------------
+
+INSERT INTO email_links (id, macro_id, fusionauth_user_id, email_address, provider, is_sync_active, created_at, updated_at)
+VALUES ('00000000-0000-0000-0000-000000000f01', 'macro|[email protected]', '00000000-0000-0000-0000-000000000f01',
+ '[email protected]', 'GMAIL', true, NOW(), NOW());
+
+------------------------------------------------------------
+-- Contact
+------------------------------------------------------------
+
+INSERT INTO email_contacts (id, link_id, email_address, created_at, updated_at)
+VALUES ('00000000-0000-0000-0000-0000000cf001',
+ '00000000-0000-0000-0000-000000000f01',
+ NOW(), NOW());
+
+------------------------------------------------------------
+-- Thread
+------------------------------------------------------------
+
+INSERT INTO email_threads (id, link_id, inbox_visible, is_read, created_at, updated_at)
+VALUES ('00000000-0000-0000-0000-00000000f201',
+ '00000000-0000-0000-0000-000000000f01',
+ true, false, NOW(), NOW());
+
+------------------------------------------------------------
+-- Draft Message 1: Has multiple attachments
+------------------------------------------------------------
+
+INSERT INTO email_messages (id, thread_id, link_id, provider_id, is_sent, from_contact_id, internal_date_ts,
+ has_attachments, is_read, is_starred, is_draft, created_at, updated_at)
+VALUES ('00000000-0000-0000-0000-00000000f501',
+ '00000000-0000-0000-0000-00000000f201',
+ '00000000-0000-0000-0000-000000000f01',
+ 'provider-draft-f501',
+ FALSE,
+ '00000000-0000-0000-0000-0000000cf001',
+ '2025-01-05 10:00:00 +00:00',
+ true, false, false, true, NOW(), NOW());
+
+-- Attachment 1: zulu_file.txt (should be last alphabetically)
+INSERT INTO email_attachments_drafts (id, draft_id, file_name, content_type, sha, size, s3_key, created_at)
+VALUES ('00000000-0000-0000-0000-0000000fa001',
+ '00000000-0000-0000-0000-00000000f501',
+ 'zulu_file.txt',
+ 'text/plain',
+ 'sha256_zulu',
+ 1500,
+ 's3://bucket/draft/f501/fa001',
+ NOW());
+
+-- Attachment 2: alpha_doc.pdf (should be first alphabetically)
+INSERT INTO email_attachments_drafts (id, draft_id, file_name, content_type, sha, size, s3_key, created_at)
+VALUES ('00000000-0000-0000-0000-0000000fa002',
+ '00000000-0000-0000-0000-00000000f501',
+ 'alpha_doc.pdf',
+ 'application/pdf',
+ 'sha256_alpha',
+ 2500,
+ 's3://bucket/draft/f501/fa002',
+ NOW());
+
+-- Attachment 3: mike_image.png (should be in the middle)
+INSERT INTO email_attachments_drafts (id, draft_id, file_name, content_type, sha, size, s3_key, created_at)
+VALUES ('00000000-0000-0000-0000-0000000fa003',
+ '00000000-0000-0000-0000-00000000f501',
+ 'mike_image.png',
+ 'image/png',
+ 'sha256_mike',
+ 3500,
+ 's3://bucket/draft/f501/fa003',
+ NOW());
+
+------------------------------------------------------------
+-- Draft Message 2: No attachments
+------------------------------------------------------------
+
+INSERT INTO email_messages (id, thread_id, link_id, provider_id, is_sent, from_contact_id, internal_date_ts,
+ has_attachments, is_read, is_starred, is_draft, created_at, updated_at)
+VALUES ('00000000-0000-0000-0000-00000000f502',
+ '00000000-0000-0000-0000-00000000f201',
+ '00000000-0000-0000-0000-000000000f01',
+ 'provider-draft-f502',
+ FALSE,
+ '00000000-0000-0000-0000-0000000cf001',
+ '2025-01-05 11:00:00 +00:00',
+ false, false, false, true, NOW(), NOW());
\ No newline at end of file
diff --git a/rust/cloud-storage/email_db_client/src/attachments/draft/mod.rs b/rust/cloud-storage/email_db_client/src/attachments/draft/mod.rs
index 1fba2667ef..734c6a4853 100644
--- a/rust/cloud-storage/email_db_client/src/attachments/draft/mod.rs
+++ b/rust/cloud-storage/email_db_client/src/attachments/draft/mod.rs
@@ -123,3 +123,24 @@ pub async fn fetch_draft_attachments_by_draft_id(
Ok(service_attachments)
}
+
+#[tracing::instrument(skip(pool), err)]
+pub async fn fetch_db_draft_attachments(
+ pool: &PgPool,
+ draft_id: Uuid,
+) -> anyhow::Result<Vec<db::attachment::AttachmentDraft>> {
+ let db_attachments = sqlx::query_as!(
+ db::attachment::AttachmentDraft,
+ r#"
+ SELECT id, draft_id, file_name, content_type, sha, size, s3_key
+ FROM email_attachments_drafts
+ WHERE draft_id = $1
+ ORDER BY file_name ASC
+ "#,
+ draft_id,
+ )
+ .fetch_all(pool)
+ .await?;
+
+ Ok(db_attachments)
+}
diff --git a/rust/cloud-storage/email_db_client/src/attachments/draft/test.rs b/rust/cloud-storage/email_db_client/src/attachments/draft/test.rs
index 094b4ddab4..2df736d88b 100644
--- a/rust/cloud-storage/email_db_client/src/attachments/draft/test.rs
+++ b/rust/cloud-storage/email_db_client/src/attachments/draft/test.rs
@@ -1,5 +1,5 @@
use crate::attachments::draft::{
- delete_draft_attachment, fetch_draft_attachments_by_draft_id,
+ delete_draft_attachment, fetch_db_draft_attachments, fetch_draft_attachments_by_draft_id,
get_total_attachments_size_by_draft_id, insert_draft_attachment,
};
use anyhow::Result;
@@ -234,3 +234,81 @@ async fn insert_draft_attachment_does_nothing_for_wrong_link_id(
Ok(())
}
+
+#[sqlx::test(
+ migrator = "MACRO_DB_MIGRATIONS",
+ fixtures(path = "../../../fixtures", scripts("fetch_db_draft_attachments"))
+)]
+async fn fetch_db_draft_attachments_returns_attachments_ordered_by_filename(
+ pool: Pool<Postgres>,
+) -> Result<()> {
+ let draft_id = Uuid::parse_str("00000000-0000-0000-0000-00000000f501")?;
+
+ let res = fetch_db_draft_attachments(&pool, draft_id).await?;
+
+ assert_eq!(res.len(), 3);
+
+ // Verify ordering by file_name ASC
+ assert_eq!(res[0].file_name, "alpha_doc.pdf");
+ assert_eq!(res[1].file_name, "mike_image.png");
+ assert_eq!(res[2].file_name, "zulu_file.txt");
+
+ Ok(())
+}
+
+#[sqlx::test(
+ migrator = "MACRO_DB_MIGRATIONS",
+ fixtures(path = "../../../fixtures", scripts("fetch_db_draft_attachments"))
+)]
+async fn fetch_db_draft_attachments_returns_correct_fields(pool: Pool<Postgres>) -> Result<()> {
+ let draft_id = Uuid::parse_str("00000000-0000-0000-0000-00000000f501")?;
+
+ let res = fetch_db_draft_attachments(&pool, draft_id).await?;
+
+ // Verify first attachment (alpha_doc.pdf) has correct fields
+ let first = &res[0];
+ assert_eq!(
+ first.id,
+ Uuid::parse_str("00000000-0000-0000-0000-0000000fa002")?
+ );
+ assert_eq!(first.draft_id, draft_id);
+ assert_eq!(first.file_name, "alpha_doc.pdf");
+ assert_eq!(first.content_type, "application/pdf");
+ assert_eq!(first.sha, "sha256_alpha");
+ assert_eq!(first.size, 2500);
+ assert_eq!(first.s3_key, "s3://bucket/draft/f501/fa002");
+
+ Ok(())
+}
+
+#[sqlx::test(
+ migrator = "MACRO_DB_MIGRATIONS",
+ fixtures(path = "../../../fixtures", scripts("fetch_db_draft_attachments"))
+)]
+async fn fetch_db_draft_attachments_returns_empty_for_draft_without_attachments(
+ pool: Pool<Postgres>,
+) -> Result<()> {
+ let draft_id = Uuid::parse_str("00000000-0000-0000-0000-00000000f502")?;
+
+ let res = fetch_db_draft_attachments(&pool, draft_id).await?;
+
+ assert_eq!(res.len(), 0);
+
+ Ok(())
+}
+
+#[sqlx::test(
+ migrator = "MACRO_DB_MIGRATIONS",
+ fixtures(path = "../../../fixtures", scripts("fetch_db_draft_attachments"))
+)]
+async fn fetch_db_draft_attachments_returns_empty_for_nonexistent_draft(
+ pool: Pool<Postgres>,
+) -> Result<()> {
+ let nonexistent_draft_id = Uuid::parse_str("00000000-0000-0000-0000-00000000ffff")?;
+
+ let res = fetch_db_draft_attachments(&pool, nonexistent_draft_id).await?;
+
+ assert_eq!(res.len(), 0);
+
+ Ok(())
+}
diff --git a/rust/cloud-storage/email_db_client/src/messages/insert.rs b/rust/cloud-storage/email_db_client/src/messages/insert.rs
index 3a011e8740..9adb79d8d4 100644
--- a/rust/cloud-storage/email_db_client/src/messages/insert.rs
+++ b/rust/cloud-storage/email_db_client/src/messages/insert.rs
@@ -112,11 +112,13 @@ async fn insert_db_message(
provider_thread_id = EXCLUDED.provider_thread_id,
replying_to_id = EXCLUDED.replying_to_id,
from_name = EXCLUDED.from_name,
+ from_contact_id = EXCLUDED.from_contact_id,
internal_date_ts = EXCLUDED.internal_date_ts,
snippet = EXCLUDED.snippet,
size_estimate = EXCLUDED.size_estimate,
subject = EXCLUDED.subject,
sent_at = EXCLUDED.sent_at,
+ has_attachments = EXCLUDED.has_attachments,
is_read = EXCLUDED.is_read,
is_starred = EXCLUDED.is_starred,
is_sent = EXCLUDED.is_sent,
diff --git a/rust/cloud-storage/email_db_client/src/parse/db_to_service.rs b/rust/cloud-storage/email_db_client/src/parse/db_to_service.rs
index c5c4f21f23..937e0d757d 100644
--- a/rust/cloud-storage/email_db_client/src/parse/db_to_service.rs
+++ b/rust/cloud-storage/email_db_client/src/parse/db_to_service.rs
@@ -104,32 +104,26 @@ pub fn map_db_macro_attachment_to_service(
}
}
-#[tracing::instrument(skip(db_message, sender_res, recipients_res, labels_res, attachments_res,))]
-pub fn map_db_message_to_service(
- db_message: db::message::Message,
- sender_res: Option<db::contact::Contact>,
- recipients_res: Vec<(db::contact::Contact, db::address::EmailRecipientType)>,
- scheduled_res: Option<db::message::ScheduledMessage>,
- labels_res: Vec<db::label::Label>,
- attachments_res: Vec<attachment::Attachment>,
- macro_attachments_res: Vec<attachment::AttachmentMacro>,
+#[tracing::instrument(skip_all)]
+pub fn map_db_message_attachments_to_service(
+ mut service_message: message::Message,
+ attachments_res: Vec<db::attachment::Attachment>,
+ macro_attachments_res: Vec<db::attachment::AttachmentMacro>,
+ draft_attachments_res: Vec<db::attachment::AttachmentDraft>,
) -> anyhow::Result<message::Message> {
- let mut service_message = map_attachmentless_db_message_to_service(
- db_message,
- sender_res,
- recipients_res,
- scheduled_res,
- labels_res,
- );
-
service_message.attachments = map_db_attachments_to_service(attachments_res);
service_message.attachments_macro = map_db_macro_attachments_to_service(macro_attachments_res);
+ service_message.attachments_draft = draft_attachments_res
+ .into_iter()
+ .map(|a| a.into())
+ .collect();
+
Ok(service_message)
}
-#[tracing::instrument(skip(db_message, recipients_res))]
+#[tracing::instrument(skip_all)]
pub fn map_db_message_to_message_to_send(
db_message: db::message::Message,
recipients_res: Vec<(db::contact::Contact, db::address::EmailRecipientType)>,
@@ -173,7 +167,7 @@ pub fn map_db_message_to_message_to_send(
// Maps the db layer message object to the service layer message object, without attachments. Kept
// separate so we don't have to pass in an s3 client for generating the attachment data urls if we
// don't need to (ex. when fetching thread metadata)
-#[tracing::instrument(skip(db_message, sender_res, recipients_res, labels_res))]
+#[tracing::instrument(skip_all)]
pub fn map_attachmentless_db_message_to_service(
db_message: db::message::Message, // Take ownership of the base message data
sender_res: Option<db::contact::Contact>,
@@ -215,6 +209,7 @@ pub fn map_attachmentless_db_message_to_service(
body_macro: db_message.body_macro,
attachments: Vec::new(),
attachments_macro: Vec::new(),
+ attachments_draft: Vec::new(),
headers_json: db_message.headers_jsonb,
created_at: db_message.created_at,
updated_at: db_message.updated_at,
diff --git a/rust/cloud-storage/email_db_client/src/threads/get.rs b/rust/cloud-storage/email_db_client/src/threads/get.rs
index 05d13ea3ca..f940cad8d4 100644
--- a/rust/cloud-storage/email_db_client/src/threads/get.rs
+++ b/rust/cloud-storage/email_db_client/src/threads/get.rs
@@ -1,4 +1,5 @@
use crate::parse::db_to_service;
+use crate::parse::db_to_service::map_attachmentless_db_message_to_service;
use crate::{attachments, contacts, labels, messages};
use anyhow::{Context, anyhow};
use futures::future::try_join_all;
@@ -130,6 +131,7 @@ pub async fn fetch_thread_with_messages_paginated(
labels_res,
attachments_res,
macro_attachments_res,
+ draft_attachments_res,
) = tokio::try_join!(
contacts::get::get_sender_by_message_id(&pool_clone, db_message.id),
contacts::get::fetch_db_recipients(&pool_clone, db_message.id),
@@ -145,18 +147,32 @@ pub async fn fetch_thread_with_messages_paginated(
},
async {
attachments::marco::fetch_db_macro_attachments(&pool_clone, db_message.id).await
- }
+ },
+ async {
+ // only need to check if the message is a draft created in Macro
+ if db_message.is_draft && db_message.provider_id.is_none() {
+ attachments::draft::fetch_db_draft_attachments(&pool_clone, db_message.id)
+ .await
+ } else {
+ Ok(Vec::new())
+ }
+ },
)?;
- // parse db-layer structs into service-layer message struct
- db_to_service::map_db_message_to_service(
+ let service_message = map_attachmentless_db_message_to_service(
db_message,
sender_res,
recipients_res,
scheduled_res,
labels_res,
+ );
+
+ // parse db-layer structs into service-layer message struct
+ db_to_service::map_db_message_attachments_to_service(
+ service_message,
attachments_res,
macro_attachments_res,
+ draft_attachments_res,
)
});
}
diff --git a/rust/cloud-storage/email_service/src/util/process_pre_insert/clean_message/remove_trailing_br_tags.rs b/rust/cloud-storage/email_service/src/util/process_pre_insert/clean_message/remove_trailing_br_tags.rs
index 4b95546d03..79b03eac63 100644
--- a/rust/cloud-storage/email_service/src/util/process_pre_insert/clean_message/remove_trailing_br_tags.rs
+++ b/rust/cloud-storage/email_service/src/util/process_pre_insert/clean_message/remove_trailing_br_tags.rs
@@ -144,6 +144,7 @@ mod tests {
body_text: None,
attachments: vec![],
attachments_macro: vec![],
+ attachments_draft: vec![],
headers_json: None,
created_at: Default::default(),
labels: vec![],
diff --git a/rust/cloud-storage/gmail_client/src/parse/message.rs b/rust/cloud-storage/gmail_client/src/parse/message.rs
index ba44c94707..f91490ba5c 100644
--- a/rust/cloud-storage/gmail_client/src/parse/message.rs
+++ b/rust/cloud-storage/gmail_client/src/parse/message.rs
@@ -100,6 +100,7 @@ pub fn map_message_resource_to_service(
body_macro: None,
attachments,
attachments_macro: Vec::new(),
+ attachments_draft: Vec::new(),
headers_json: Some(serde_json::to_value(parsed_payload.all_headers)?),
created_at: Utc::now(), // Omitted - set default/ignored
updated_at: Utc::now(), // Omitted - set default/ignored
diff --git a/rust/cloud-storage/models_email/src/email/service/attachment.rs b/rust/cloud-storage/models_email/src/email/service/attachment.rs
index ecf4ad7fd1..f62f3e410c 100644
--- a/rust/cloud-storage/models_email/src/email/service/attachment.rs
+++ b/rust/cloud-storage/models_email/src/email/service/attachment.rs
@@ -87,7 +87,7 @@ pub enum AttachmentUploadDestination {
Sfs,
}
-#[derive(Debug, Clone)]
+#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
pub struct AttachmentDraft {
/// Unique identifier for the attachment.
pub id: Uuid,
diff --git a/rust/cloud-storage/models_email/src/email/service/body_parsing/body_replyless/mod.rs b/rust/cloud-storage/models_email/src/email/service/body_parsing/body_replyless/mod.rs
index a2fc97de49..cb6b3e0644 100644
--- a/rust/cloud-storage/models_email/src/email/service/body_parsing/body_replyless/mod.rs
+++ b/rust/cloud-storage/models_email/src/email/service/body_parsing/body_replyless/mod.rs
@@ -124,6 +124,7 @@ mod tests {
body_text: None,
attachments: vec![],
attachments_macro: vec![],
+ attachments_draft: vec![],
headers_json: None,
created_at: Default::default(),
labels: vec![],
diff --git a/rust/cloud-storage/models_email/src/email/service/message.rs b/rust/cloud-storage/models_email/src/email/service/message.rs
index 970908ef59..e939a970ce 100644
--- a/rust/cloud-storage/models_email/src/email/service/message.rs
+++ b/rust/cloud-storage/models_email/src/email/service/message.rs
@@ -2,7 +2,7 @@ use crate::db;
use crate::email::service::address::ContactInfo;
use crate::email::service::attachment::Attachment;
use crate::email::service::label::{LabelInfo, system_labels};
-use crate::service::attachment::{AttachmentMacro, AttachmentToSend};
+use crate::service::attachment::{AttachmentDraft, AttachmentMacro, AttachmentToSend};
use crate::service::body_parsing::body_parsed::{
get_body_parsed_for_message, get_body_parsed_linkless_for_message,
};
@@ -87,6 +87,8 @@ pub struct Message {
pub body_macro: Option<String>,
pub attachments: Vec<Attachment>,
pub attachments_macro: Vec<AttachmentMacro>,
+ /// Uploaded file attachments for the message, if it is a draft
+ pub attachments_draft: Vec<AttachmentDraft>,
pub headers_json: Option<JsonValue>,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,