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.

fix(email-service): Better attachment upload checking (#207)

Evan Hutnik7904815f4965
diff --git a/rust/cloud-storage/email_service/src/pubsub/webhook/operations/upsert_message.rs b/rust/cloud-storage/email_service/src/pubsub/webhook/operations/upsert_message.rs
index e1a2e36f6d..68ba521829 100644
--- a/rust/cloud-storage/email_service/src/pubsub/webhook/operations/upsert_message.rs
+++ b/rust/cloud-storage/email_service/src/pubsub/webhook/operations/upsert_message.rs
@@ -64,6 +64,7 @@ pub async fn upsert_message(
return Ok(());
}
};
+ let message_attachment_count = message.attachments.len();
// will always exist because we just fetched it
let provider_thread_id = message.provider_thread_id.clone().unwrap();
@@ -130,7 +131,10 @@ pub async fn upsert_message(
notify_for_new_messages(ctx, link, new_message_provider_ids).await?;
// temporarily only for macro emails, for testing purposes
- if link.macro_id.ends_with("@macro.com") && !cfg!(feature = "disable_attachment_upload") {
+ if link.macro_id.ends_with("@macro.com")
+ && !cfg!(feature = "disable_attachment_upload")
+ && message_attachment_count > 0
+ {
// upload attachments to Macro
let attachments = email_db_client::attachments::provider::upload::fetch_insertable_attachments_for_new_email(
&ctx.db,
diff --git a/rust/cloud-storage/gmail_client/src/watch.rs b/rust/cloud-storage/gmail_client/src/watch.rs
index d42e1741a8..cb93ecc3dd 100644
--- a/rust/cloud-storage/gmail_client/src/watch.rs
+++ b/rust/cloud-storage/gmail_client/src/watch.rs
@@ -42,7 +42,7 @@ pub(crate) async fn register_watch(
.await
.unwrap_or_else(|_| "Failed to read error body".to_string());
return Err(GmailError::ApiError(format!(
- "Gmail API error ({}): {}",
+ "({}): {}",
status, error_body
)));
}
diff --git a/rust/cloud-storage/models_email/src/gmail/error.rs b/rust/cloud-storage/models_email/src/gmail/error.rs
index 211ae7f94e..6cd9559747 100644
--- a/rust/cloud-storage/models_email/src/gmail/error.rs
+++ b/rust/cloud-storage/models_email/src/gmail/error.rs
@@ -11,7 +11,7 @@ pub enum GmailError {
#[error("HTTP Request Error: {0}")]
HttpRequest(String),
- #[error("API Error")]
+ #[error("API Error: {0}")]
ApiError(String),
#[error("Multipart Parsing Error: {0}")]