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
feat(email): support replying from a different inbox than the thread's (#3733)
gbirman0efaa57170a5
diff --git a/rust/cloud-storage/.sqlx/query-c3f8291d5ce84fb1eb463eaa0f0aed0c3ac2ed1297f345941cc8c2bfdcadedd5.json b/rust/cloud-storage/.sqlx/query-60707c986f365c7b49d1938285b601338c1d98e45b630d1a3e1622fb16ad58b6.jsonsimilarity index 52%rename from rust/cloud-storage/.sqlx/query-c3f8291d5ce84fb1eb463eaa0f0aed0c3ac2ed1297f345941cc8c2bfdcadedd5.jsonrename to rust/cloud-storage/.sqlx/query-60707c986f365c7b49d1938285b601338c1d98e45b630d1a3e1622fb16ad58b6.jsonindex d93442c86c..395a3e1776 100644--- a/rust/cloud-storage/.sqlx/query-c3f8291d5ce84fb1eb463eaa0f0aed0c3ac2ed1297f345941cc8c2bfdcadedd5.json+++ b/rust/cloud-storage/.sqlx/query-60707c986f365c7b49d1938285b601338c1d98e45b630d1a3e1622fb16ad58b6.json@@ -1,6 +1,6 @@{"db_name": "PostgreSQL",- "query": "\n SELECT\n m.id,\n m.thread_id,\n m.provider_thread_id,\n m.headers_jsonb,\n m.is_sent,\n m.is_draft\n FROM email_messages m\n WHERE m.link_id = $1\n AND m.is_draft = true\n AND jsonb_path_exists(\n m.headers_jsonb,\n '$[*] ? (@.\"Macro-In-Reply-To\" == $macro_uuid)'::jsonpath,\n jsonb_build_object('macro_uuid', $2::text)\n )\n ORDER BY m.created_at DESC\n LIMIT 1\n ",+ "query": "\n SELECT\n m.id,\n m.link_id,\n m.thread_id,\n m.provider_thread_id,\n m.headers_jsonb,\n m.is_sent,\n m.is_draft\n FROM email_messages m\n WHERE m.link_id = $1\n AND m.is_draft = true\n AND jsonb_path_exists(\n m.headers_jsonb,\n '$[*] ? (@.\"Macro-In-Reply-To\" == $macro_uuid)'::jsonpath,\n jsonb_build_object('macro_uuid', $2::text)\n )\n ORDER BY m.created_at DESC\n LIMIT 1\n ","describe": {"columns": [{@@ -10,26 +10,31 @@},{"ordinal": 1,- "name": "thread_id",+ "name": "link_id","type_info": "Uuid"},{"ordinal": 2,+ "name": "thread_id",+ "type_info": "Uuid"+ },+ {+ "ordinal": 3,"name": "provider_thread_id","type_info": "Text"},{- "ordinal": 3,+ "ordinal": 4,"name": "headers_jsonb","type_info": "Jsonb"},{- "ordinal": 4,+ "ordinal": 5,"name": "is_sent","type_info": "Bool"},{- "ordinal": 5,+ "ordinal": 6,"name": "is_draft","type_info": "Bool"}@@ -41,6 +46,7 @@]},"nullable": [+ false,false,false,true,@@ -49,5 +55,5 @@false]},- "hash": "c3f8291d5ce84fb1eb463eaa0f0aed0c3ac2ed1297f345941cc8c2bfdcadedd5"+ "hash": "60707c986f365c7b49d1938285b601338c1d98e45b630d1a3e1622fb16ad58b6"}diff --git a/rust/cloud-storage/.sqlx/query-37c7a9fd9f1156ce7de8a691fab1d33b9b50bd1e3525338b49991091df258321.json b/rust/cloud-storage/.sqlx/query-64335bf8a0c673f907b40511dc568f1cd36c04d98b98016eaed27a98622c05c4.jsonsimilarity index 61%rename from rust/cloud-storage/.sqlx/query-37c7a9fd9f1156ce7de8a691fab1d33b9b50bd1e3525338b49991091df258321.jsonrename to rust/cloud-storage/.sqlx/query-64335bf8a0c673f907b40511dc568f1cd36c04d98b98016eaed27a98622c05c4.jsonindex cf6201e995..3760d059dc 100644--- a/rust/cloud-storage/.sqlx/query-37c7a9fd9f1156ce7de8a691fab1d33b9b50bd1e3525338b49991091df258321.json+++ b/rust/cloud-storage/.sqlx/query-64335bf8a0c673f907b40511dc568f1cd36c04d98b98016eaed27a98622c05c4.json@@ -1,6 +1,6 @@{"db_name": "PostgreSQL",- "query": "\n SELECT\n m.id,\n m.thread_id,\n m.provider_thread_id,\n m.headers_jsonb,\n m.is_sent,\n m.is_draft\n FROM email_messages m\n WHERE m.id = $1 AND m.link_id = $2\n ",+ "query": "\n SELECT\n m.id,\n m.link_id,\n m.thread_id,\n m.provider_thread_id,\n m.headers_jsonb,\n m.is_sent,\n m.is_draft\n FROM email_messages m\n WHERE m.id = $1 AND m.link_id = ANY($2)\n ","describe": {"columns": [{@@ -10,26 +10,31 @@},{"ordinal": 1,- "name": "thread_id",+ "name": "link_id","type_info": "Uuid"},{"ordinal": 2,+ "name": "thread_id",+ "type_info": "Uuid"+ },+ {+ "ordinal": 3,"name": "provider_thread_id","type_info": "Text"},{- "ordinal": 3,+ "ordinal": 4,"name": "headers_jsonb","type_info": "Jsonb"},{- "ordinal": 4,+ "ordinal": 5,"name": "is_sent","type_info": "Bool"},{- "ordinal": 5,+ "ordinal": 6,"name": "is_draft","type_info": "Bool"}@@ -37,10 +42,11 @@"parameters": {"Left": ["Uuid",- "Uuid"+ "UuidArray"]},"nullable": [+ false,false,false,true,@@ -49,5 +55,5 @@false]},- "hash": "37c7a9fd9f1156ce7de8a691fab1d33b9b50bd1e3525338b49991091df258321"+ "hash": "64335bf8a0c673f907b40511dc568f1cd36c04d98b98016eaed27a98622c05c4"}diff --git a/rust/cloud-storage/email/src/domain/models/draft.rs b/rust/cloud-storage/email/src/domain/models/draft.rsindex 6856d4005a..4c1d1d7210 100644--- a/rust/cloud-storage/email/src/domain/models/draft.rs+++ b/rust/cloud-storage/email/src/domain/models/draft.rs@@ -76,6 +76,8 @@ pub struct ResolvedDraftInput {pub struct SimpleMessageInfo {/// Database ID of the message.pub db_id: Uuid,+ /// The inbox (link) the message belongs to.+ pub link_id: Uuid,/// Thread database ID.pub thread_db_id: Uuid,/// Provider thread ID.diff --git a/rust/cloud-storage/email/src/domain/ports.rs b/rust/cloud-storage/email/src/domain/ports.rsindex 30fd603328..3ae371d033 100644--- a/rust/cloud-storage/email/src/domain/ports.rs+++ b/rust/cloud-storage/email/src/domain/ports.rs@@ -146,11 +146,12 @@ pub trait EmailRepo: Send + Sync + 'static {message_ids: &[Uuid],) -> impl Future<Output = Result<HashMap<Uuid, DateTime<Utc>>, Self::Err>> + Send;- /// Fetch a simplified message by its DB ID and link ID (for validation).+ /// Fetch a simplified message by its DB ID, scoped to a set of accessible+ /// inbox link IDs (for validation across own + delegated inboxes).fn get_simple_message(&self,message_id: Uuid,- link_id: Uuid,+ link_ids: &[Uuid],) -> impl Future<Output = Result<Option<SimpleMessageInfo>, Self::Err>> + Send;/// Find an existing draft that replies to the given message ID.@@ -362,17 +363,23 @@ pub trait EmailService: Send + Sync + 'static {limit: i64,) -> impl Future<Output = Result<Option<ParsedThread>, EmailErr>> + Send;- /// Create a draft message for the given link.+ /// Create a draft message sent from `link`. `accessible_inboxes` is every+ /// inbox the caller can reach (own + delegated); a reply target may live in+ /// any of them, not just `link`.fn create_draft(&self,link: &Link,+ accessible_inboxes: &[Link],input: CreateDraftInput,) -> impl Future<Output = Result<CreatedDraft, EmailErr>> + Send;/// Send a message: persist it and enqueue for scheduled delivery.+ /// `accessible_inboxes` is every inbox the caller can reach (own ++ /// delegated); a reply target may live in any of them, not just `link`.fn send_message(&self,link: &Link,+ accessible_inboxes: &[Link],input: CreateDraftInput,) -> impl Future<Output = Result<CreatedDraft, EmailErr>> + Send;diff --git a/rust/cloud-storage/email/src/domain/service/draft.rs b/rust/cloud-storage/email/src/domain/service/draft.rsindex c4f0ba45df..d6ff5aaefd 100644--- a/rust/cloud-storage/email/src/domain/service/draft.rs+++ b/rust/cloud-storage/email/src/domain/service/draft.rs@@ -20,13 +20,15 @@ whereCS: crm::domain::service::CrmService,anyhow::Error: From<T::Err>,{- #[tracing::instrument(err, skip(self, link, input))]+ #[tracing::instrument(err, skip(self, link, accessible_inboxes, input))]pub(crate) async fn create_draft_impl(&self,link: &Link,+ accessible_inboxes: &[Link],input: CreateDraftInput,) -> Result<CreatedDraft, EmailErr> {- self.prepare_and_insert_db_message(link, input, true).await+ self.prepare_and_insert_db_message(link, accessible_inboxes, input, true)+ .await}/// Shared pipeline for creating a draft or a sent message.@@ -34,18 +36,21 @@ where/// Validates existing message / reply-to, decodes HTML body, upserts contacts,/// builds thread if needed, and inserts the message row via the repo layer./// `is_draft` controls the `is_draft` flag persisted on the message row.- #[tracing::instrument(err, skip(self, link, input))]+ #[tracing::instrument(err, skip(self, link, accessible_inboxes, input))]pub(crate) async fn prepare_and_insert_db_message(&self,link: &Link,+ accessible_inboxes: &[Link],mut input: CreateDraftInput,is_draft: bool,) -> Result<CreatedDraft, EmailErr> {let link_id = link.id;+ let accessible_link_ids: Vec<Uuid> = accessible_inboxes.iter().map(|l| l.id).collect();self.validate_existing_message(link_id, &mut input).await?;- self.validate_replying_to(link_id, &mut input).await?;+ self.validate_replying_to(link_id, &accessible_link_ids, &mut input)+ .await?;decode_html_body(&mut input)?;@@ -124,7 +129,7 @@ wherelet msg = self.email_repo- .get_simple_message(db_id, link_id)+ .get_simple_message(db_id, &[link_id]).await.map_err(anyhow::Error::from)?.ok_or(EmailErr::MessageNotFound(db_id))?;@@ -142,13 +147,14 @@ whereasync fn validate_replying_to(&self,link_id: Uuid,+ accessible_link_ids: &[Uuid],input: &mut CreateDraftInput,) -> Result<(), EmailErr> {let Some(replying_to_id) = input.replying_to_id else {return Ok(());};- // Check if a draft already exists replying to this message+ // The draft replying to this message lives in the inbox being sent from.if let Some(existing_draft) = self.email_repo.get_draft_replying_to(link_id, replying_to_id)@@ -157,7 +163,7 @@ where{self.apply_existing_draft(input, existing_draft);} else {- self.apply_reply_target(link_id, input, replying_to_id)+ self.apply_reply_target(link_id, accessible_link_ids, input, replying_to_id).await?;}@@ -178,12 +184,13 @@ whereasync fn apply_reply_target(&self,link_id: Uuid,+ accessible_link_ids: &[Uuid],input: &mut CreateDraftInput,replying_to_id: Uuid,) -> Result<(), EmailErr> {let reply_target = self.email_repo- .get_simple_message(replying_to_id, link_id)+ .get_simple_message(replying_to_id, accessible_link_ids).await.map_err(anyhow::Error::from)?.ok_or(EmailErr::MessageNotFound(replying_to_id))?;@@ -192,8 +199,18 @@ wherereturn Err(EmailErr::CannotReplyToDraft);}- input.thread_db_id = Some(reply_target.thread_db_id);- input.provider_thread_id = reply_target.provider_thread_id;+ if reply_target.link_id == link_id {+ // Same inbox: thread into the target's existing thread.+ input.thread_db_id = Some(reply_target.thread_db_id);+ input.provider_thread_id = reply_target.provider_thread_id;+ } else {+ // The target lives in a different inbox (a different provider+ // account), so it cannot thread into that account's provider+ // thread. Start a fresh thread in the sending inbox; the+ // Macro-In-Reply-To header below preserves the reference.+ input.thread_db_id = None;+ input.provider_thread_id = None;+ }// Generate Macro-In-Reply-To headerinput.headers_json = Some(serde_json::json!([{diff --git a/rust/cloud-storage/email/src/domain/service/mod.rs b/rust/cloud-storage/email/src/domain/service/mod.rsindex 25cb914ff8..b7efd056eb 100644--- a/rust/cloud-storage/email/src/domain/service/mod.rs+++ b/rust/cloud-storage/email/src/domain/service/mod.rs@@ -192,17 +192,21 @@ whereasync fn create_draft(&self,link: &Link,+ accessible_inboxes: &[Link],input: CreateDraftInput,) -> Result<CreatedDraft, EmailErr> {- self.create_draft_impl(link, input).await+ self.create_draft_impl(link, accessible_inboxes, input)+ .await}async fn send_message(&self,link: &Link,+ accessible_inboxes: &[Link],input: CreateDraftInput,) -> Result<CreatedDraft, EmailErr> {- self.send_message_impl(link, input).await+ self.send_message_impl(link, accessible_inboxes, input)+ .await}async fn list_labels(&self, link: &Link) -> Result<Vec<LinkLabel>, EmailErr> {diff --git a/rust/cloud-storage/email/src/domain/service/send.rs b/rust/cloud-storage/email/src/domain/service/send.rsindex bc1264a14f..a5c1af530e 100644--- a/rust/cloud-storage/email/src/domain/service/send.rs+++ b/rust/cloud-storage/email/src/domain/service/send.rs@@ -17,17 +17,18 @@ whereanyhow::Error: From<T::Err>,anyhow::Error: From<E::Err>,{- #[tracing::instrument(err, skip(self, link, input))]+ #[tracing::instrument(err, skip(self, link, accessible_inboxes, input))]pub(crate) async fn send_message_impl(&self,link: &Link,+ accessible_inboxes: &[Link],mut input: CreateDraftInput,) -> Result<CreatedDraft, EmailErr> {let delay_secs = self.sent_undo_delay_secs;input.send_time = Some(chrono::Utc::now() + Duration::seconds(delay_secs as i64));let created = self- .prepare_and_insert_db_message(link, input, false)+ .prepare_and_insert_db_message(link, accessible_inboxes, input, false).await?;// FE displays "Undo" button for delay_secs. Give extra time for round trip of cancel requestdiff --git a/rust/cloud-storage/email/src/inbound/axum/draft_router.rs b/rust/cloud-storage/email/src/inbound/axum/draft_router.rsindex c0a7a2b96a..7796900588 100644--- a/rust/cloud-storage/email/src/inbound/axum/draft_router.rs+++ b/rust/cloud-storage/email/src/inbound/axum/draft_router.rs@@ -7,7 +7,7 @@ use crate::domain::{models::EmailErr, ports::EmailService};use super::{api_types::{CreateDraftRequest, CreateDraftResponse},- axum_impls::EmailLinkExtractor,+ axum_impls::{EmailLinkExtractor, MultiEmailLinkExtractor},previews_router::EmailRouterState,};@@ -86,14 +86,18 @@ impl From<EmailErr> for CreateDraftError {(status = 500, body = ErrorResponse),))]-#[tracing::instrument(err, skip(state, link, body))]+#[tracing::instrument(err, skip(state, link, accessible_inboxes, body))]pub async fn create_draft_handler<T: EmailService>(State(state): State<EmailRouterState<T>>,Cached(EmailLinkExtractor(link, _)): Cached<EmailLinkExtractor<T>>,+ Cached(MultiEmailLinkExtractor(accessible_inboxes, _)): Cached<MultiEmailLinkExtractor<T>>,Json(body): Json<CreateDraftRequest>,) -> Result<impl IntoResponse, CreateDraftError> {let input = body.into_domain();- let draft = state.inner.create_draft(&link, input).await?;+ let draft = state+ .inner+ .create_draft(&link, &accessible_inboxes, input)+ .await?;Ok((StatusCode::CREATED,diff --git a/rust/cloud-storage/email/src/inbound/axum/send_router.rs b/rust/cloud-storage/email/src/inbound/axum/send_router.rsindex c6230e6878..da1ffb748a 100644--- a/rust/cloud-storage/email/src/inbound/axum/send_router.rs+++ b/rust/cloud-storage/email/src/inbound/axum/send_router.rs@@ -7,7 +7,7 @@ use crate::domain::{models::EmailErr, ports::EmailService};use super::{api_types::{SendMessageRequest, SendMessageResponse},- axum_impls::EmailLinkExtractor,+ axum_impls::{EmailLinkExtractor, MultiEmailLinkExtractor},previews_router::EmailRouterState,};@@ -86,14 +86,18 @@ impl From<EmailErr> for SendMessageError {(status = 500, body = ErrorResponse),))]-#[tracing::instrument(err, skip(state, link, body))]+#[tracing::instrument(err, skip(state, link, accessible_inboxes, body))]pub async fn send_message_handler<T: EmailService>(State(state): State<EmailRouterState<T>>,Cached(EmailLinkExtractor(link, _)): Cached<EmailLinkExtractor<T>>,+ Cached(MultiEmailLinkExtractor(accessible_inboxes, _)): Cached<MultiEmailLinkExtractor<T>>,Json(body): Json<SendMessageRequest>,) -> Result<impl IntoResponse, SendMessageError> {let input = body.into_domain();- let created = state.inner.send_message(&link, input).await?;+ let created = state+ .inner+ .send_message(&link, &accessible_inboxes, input)+ .await?;Ok((StatusCode::CREATED,diff --git a/rust/cloud-storage/email/src/inbound/toolset/send_email.rs b/rust/cloud-storage/email/src/inbound/toolset/send_email.rsindex 88215b2d57..16ae822df2 100644--- a/rust/cloud-storage/email/src/inbound/toolset/send_email.rs+++ b/rust/cloud-storage/email/src/inbound/toolset/send_email.rs@@ -124,7 +124,7 @@ wherelet sent = service_context.service- .send_message(&link, input)+ .send_message(&link, std::slice::from_ref(&link), input).await.map_err(|e| ToolCallError {description: format!("Failed to send email: {e}"),diff --git a/rust/cloud-storage/email/src/outbound/email_pg_repo/db_types.rs b/rust/cloud-storage/email/src/outbound/email_pg_repo/db_types.rsindex fb0628c6d7..055642f33a 100644--- a/rust/cloud-storage/email/src/outbound/email_pg_repo/db_types.rs+++ b/rust/cloud-storage/email/src/outbound/email_pg_repo/db_types.rs@@ -444,6 +444,7 @@ impl From<DbRecipientRow> for (uuid::Uuid, ContactInfo, RecipientType) {/// DB row for a simplified message used in draft validation queries.pub(crate) struct DbSimpleMessageRow {pub id: Uuid,+ pub link_id: Uuid,pub thread_id: Uuid,pub provider_thread_id: Option<String>,pub headers_jsonb: Option<serde_json::Value>,@@ -455,6 +456,7 @@ impl From<DbSimpleMessageRow> for SimpleMessageInfo {fn from(row: DbSimpleMessageRow) -> Self {Self {db_id: row.id,+ link_id: row.link_id,thread_db_id: row.thread_id,provider_thread_id: row.provider_thread_id,headers_json: row.headers_jsonb,diff --git a/rust/cloud-storage/email/src/outbound/email_pg_repo/message.rs b/rust/cloud-storage/email/src/outbound/email_pg_repo/message.rsindex af0119bb0e..d42d608950 100644--- a/rust/cloud-storage/email/src/outbound/email_pg_repo/message.rs+++ b/rust/cloud-storage/email/src/outbound/email_pg_repo/message.rs@@ -271,28 +271,31 @@ pub(super) async fn scheduled_send_times_by_message_ids(.collect())}-/// Fetch a simplified message by DB ID and link ID for validation.+/// Fetch a simplified message by DB ID, scoped to a set of accessible inboxes,+/// for validation. Returns the message's own `link_id` so callers can tell+/// whether the reply target lives in the inbox being sent from.#[tracing::instrument(skip(pool), err)]pub(crate) async fn get_simple_message(pool: &PgPool,message_id: Uuid,- link_id: Uuid,+ link_ids: &[Uuid],) -> Result<Option<SimpleMessageInfo>, sqlx::Error> {let row = sqlx::query_as!(DbSimpleMessageRow,r#"SELECTm.id,+ m.link_id,m.thread_id,m.provider_thread_id,m.headers_jsonb,m.is_sent,m.is_draftFROM email_messages m- WHERE m.id = $1 AND m.link_id = $2+ WHERE m.id = $1 AND m.link_id = ANY($2)"#,message_id,- link_id,+ link_ids,).fetch_optional(pool).await?;@@ -313,6 +316,7 @@ pub(crate) async fn get_draft_replying_to(r#"SELECTm.id,+ m.link_id,m.thread_id,m.provider_thread_id,m.headers_jsonb,diff --git a/rust/cloud-storage/email/src/outbound/email_pg_repo/mod.rs b/rust/cloud-storage/email/src/outbound/email_pg_repo/mod.rsindex 75eda20e8d..b3a727276e 100644--- a/rust/cloud-storage/email/src/outbound/email_pg_repo/mod.rs+++ b/rust/cloud-storage/email/src/outbound/email_pg_repo/mod.rs@@ -177,9 +177,9 @@ impl EmailRepo for EmailPgRepo {async fn get_simple_message(&self,message_id: Uuid,- link_id: Uuid,+ link_ids: &[Uuid],) -> Result<Option<SimpleMessageInfo>, Self::Err> {- message::get_simple_message(&self.pool, message_id, link_id).await+ message::get_simple_message(&self.pool, message_id, link_ids).await}async fn get_draft_replying_to(diff --git a/rust/cloud-storage/email/src/outbound/email_pg_repo/test/draft.rs b/rust/cloud-storage/email/src/outbound/email_pg_repo/test/draft.rsindex 1b4b9d8913..643554f98c 100644--- a/rust/cloud-storage/email/src/outbound/email_pg_repo/test/draft.rs+++ b/rust/cloud-storage/email/src/outbound/email_pg_repo/test/draft.rs@@ -17,10 +17,11 @@ async fn test_get_simple_message_found(pool: Pool<Postgres>) -> anyhow::Result<(let msg_id = Uuid::parse_str("ee000001-0000-0000-0000-000000000001")?;let link_id = Uuid::parse_str("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa")?;- let result = repo.get_simple_message(msg_id, link_id).await?;+ let result = repo.get_simple_message(msg_id, &[link_id]).await?;let info = result.expect("Message should be found");assert_eq!(info.db_id, msg_id);+ assert_eq!(info.link_id, link_id);assert_eq!(info.thread_db_id,Uuid::parse_str("11111111-1111-1111-1111-111111111111")?@@ -44,13 +45,36 @@ async fn test_get_simple_message_wrong_link_id(pool: Pool<Postgres>) -> anyhow::let msg_id = Uuid::parse_str("ee000001-0000-0000-0000-000000000001")?;let wrong_link = Uuid::parse_str("bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb")?;- let result = repo.get_simple_message(msg_id, wrong_link).await?;+ let result = repo.get_simple_message(msg_id, &[wrong_link]).await?;assert!(result.is_none(), "Wrong link_id should return None");Ok(())}+#[sqlx::test(+ migrator = "MACRO_DB_MIGRATIONS",+ fixtures(path = "../../../../fixtures", scripts("email_draft"))+)]+async fn test_get_simple_message_across_inboxes(pool: Pool<Postgres>) -> anyhow::Result<()> {+ let repo = EmailPgRepo::new(pool);++ let msg_id = Uuid::parse_str("ee000001-0000-0000-0000-000000000001")?;+ let owning_link = Uuid::parse_str("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa")?;+ let other_link = Uuid::parse_str("bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb")?;+ let result = repo+ .get_simple_message(msg_id, &[other_link, owning_link])+ .await?;++ let info = result.expect("Message should be found across the accessible inboxes");+ assert_eq!(+ info.link_id, owning_link,+ "Should report the inbox the message actually lives in"+ );++ Ok(())+}+#[sqlx::test(migrator = "MACRO_DB_MIGRATIONS",fixtures(path = "../../../../fixtures", scripts("email_draft"))@@ -60,7 +84,7 @@ async fn test_get_simple_message_not_found(pool: Pool<Postgres>) -> anyhow::Resulet missing = Uuid::parse_str("99999999-9999-9999-9999-999999999999")?;let link_id = Uuid::parse_str("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa")?;- let result = repo.get_simple_message(missing, link_id).await?;+ let result = repo.get_simple_message(missing, &[link_id]).await?;assert!(result.is_none());@@ -76,7 +100,7 @@ async fn test_get_simple_message_draft_with_headers(pool: Pool<Postgres>) -> anylet msg_id = Uuid::parse_str("ee000002-0000-0000-0000-000000000002")?;let link_id = Uuid::parse_str("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa")?;- let result = repo.get_simple_message(msg_id, link_id).await?;+ let result = repo.get_simple_message(msg_id, &[link_id]).await?;let info = result.expect("Draft should be found");assert!(info.is_draft);diff --git a/rust/cloud-storage/soup/src/inbound/axum_router/tests.rs b/rust/cloud-storage/soup/src/inbound/axum_router/tests.rsindex 17f7899d85..5cd1f2f458 100644--- a/rust/cloud-storage/soup/src/inbound/axum_router/tests.rs+++ b/rust/cloud-storage/soup/src/inbound/axum_router/tests.rs@@ -196,6 +196,7 @@ impl EmailService for MockEmail {async fn create_draft(&self,_link: &email::domain::models::Link,+ _accessible_inboxes: &[email::domain::models::Link],_input: email::domain::models::CreateDraftInput,) -> Result<email::domain::models::CreatedDraft, EmailErr> {Err(EmailErr::RepoErr(anyhow::anyhow!("Not implemented")))@@ -204,6 +205,7 @@ impl EmailService for MockEmail {async fn send_message(&self,_link: &email::domain::models::Link,+ _accessible_inboxes: &[email::domain::models::Link],_input: email::domain::models::CreateDraftInput,) -> Result<email::domain::models::CreatedDraft, EmailErr> {Err(EmailErr::RepoErr(anyhow::anyhow!("Not implemented")))@@ -485,6 +487,7 @@ impl EmailService for MockEmailLinkResult {async fn create_draft(&self,_link: &email::domain::models::Link,+ _accessible_inboxes: &[email::domain::models::Link],_input: email::domain::models::CreateDraftInput,) -> Result<email::domain::models::CreatedDraft, EmailErr> {Err(EmailErr::RepoErr(anyhow::anyhow!("Not implemented")))@@ -493,6 +496,7 @@ impl EmailService for MockEmailLinkResult {async fn send_message(&self,_link: &email::domain::models::Link,+ _accessible_inboxes: &[email::domain::models::Link],_input: email::domain::models::CreateDraftInput,) -> Result<email::domain::models::CreatedDraft, EmailErr> {Err(EmailErr::RepoErr(anyhow::anyhow!("Not implemented")))