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(task): create task for non-team members (#3483)
Will Hutchinsona4b4335abd80
diff --git a/rust/cloud-storage/documents/src/domain/create/mod.rs b/rust/cloud-storage/documents/src/domain/create/mod.rsindex 9834d3a43d..b1fc6e8d67 100644--- a/rust/cloud-storage/documents/src/domain/create/mod.rs+++ b/rust/cloud-storage/documents/src/domain/create/mod.rs@@ -501,18 +501,14 @@ where} => Some((property_values.clone(), *share_with_team, *team_id)),};- let resolved_team_id = if let Some((_, _, requested_team_id)) = task.as_ref() {- Some(- self.document_service- .resolve_task_team_id(user_id.clone(), *requested_team_id)- .await?,- )+ let task_name = metadata.document_name.clone();+ let project_id = metadata.project_id;+ let team_id = if let Some((_, _, team_id)) = task.as_ref() {+ *team_id} else {None};- let task_name = metadata.document_name.clone();- let project_id = metadata.project_id;let args = metadata.into_repo_args(user_id.clone(),RepoDocumentKind {@@ -523,7 +519,7 @@ where} else {RepoDocumentSubtype::Regular},- team_id: resolved_team_id,+ team_id,},);@@ -540,7 +536,7 @@ where.clone();let finalize_result = async {- if let Some((property_values, share_with_team, _)) = task {+ if let Some((property_values, share_with_team, team_id)) = task {self.document_service.handle_task_properties(user_id,@@ -549,7 +545,7 @@ wheretask_name,markdown: None,project_id,- team_id: resolved_team_id,+ team_id,property_values,share_with_team,},diff --git a/rust/cloud-storage/documents/src/domain/ports/create/mod.rs b/rust/cloud-storage/documents/src/domain/ports/create/mod.rsindex d4464d6ab3..ed22c3fe29 100644--- a/rust/cloud-storage/documents/src/domain/ports/create/mod.rs+++ b/rust/cloud-storage/documents/src/domain/ports/create/mod.rs@@ -48,13 +48,6 @@ pub trait DocumentCreationService: Send + Sync {request: &CreateTaskRequest,) -> impl Future<Output = Result<(), DocumentError>> + Send;- /// Resolve the team to use for per-team task numbering.- fn resolve_task_team_id(- &self,- user_id: MacroUserIdStr<'static>,- requested_team_id: Option<uuid::Uuid>,- ) -> impl Future<Output = Result<uuid::Uuid, DocumentError>> + Send;-/// Mark a created document's upload/finalization lifecycle as complete.fn mark_document_uploaded(&self,@@ -96,16 +89,6 @@ where.await}- async fn resolve_task_team_id(- &self,- user_id: MacroUserIdStr<'static>,- requested_team_id: Option<uuid::Uuid>,- ) -> Result<uuid::Uuid, DocumentError> {- (**self)- .resolve_task_team_id(user_id, requested_team_id)- .await- }-async fn mark_document_uploaded(&self, document_id: &str) -> Result<(), DocumentError> {(**self).mark_document_uploaded(document_id).await}diff --git a/rust/cloud-storage/documents/src/domain/ports/mod.rs b/rust/cloud-storage/documents/src/domain/ports/mod.rsindex 03e577a6dc..6ac89dc16b 100644--- a/rust/cloud-storage/documents/src/domain/ports/mod.rs+++ b/rust/cloud-storage/documents/src/domain/ports/mod.rs@@ -330,13 +330,6 @@ pub trait DocumentService: Send + Sync + 'static {job_id: Option<String>,) -> impl Future<Output = Result<CreateDocumentResponseData, DocumentError>> + Send;- /// Resolve the team to use for per-team task numbering.- fn resolve_task_team_id(- &self,- user_id: MacroUserIdStr<'static>,- requested_team_id: Option<uuid::Uuid>,- ) -> impl Future<Output = Result<uuid::Uuid, DocumentError>> + Send;-/// Get content lifecycle metadata for a document.fn get_document_content(&self,diff --git a/rust/cloud-storage/documents/src/domain/service.rs b/rust/cloud-storage/documents/src/domain/service.rsindex 7d607bd597..e153ca42eb 100644--- a/rust/cloud-storage/documents/src/domain/service.rs+++ b/rust/cloud-storage/documents/src/domain/service.rs@@ -377,38 +377,6 @@ impl<}}- async fn resolve_task_team_id_for_user(- &self,- user_id: &MacroUserIdStr<'_>,- requested_team_id: Option<uuid::Uuid>,- ) -> Result<uuid::Uuid, DocumentError> {- let team_ids = self- .repo- .get_team_ids_for_user(user_id.as_ref())- .await- .map_err(|e| DocumentError::Internal(e.into()))?;-- if let Some(requested_team_id) = requested_team_id {- if team_ids.contains(&requested_team_id) {- return Ok(requested_team_id);- }-- return Err(DocumentError::BadRequest(- "user is not a member of the requested team".to_string(),- ));- }-- match team_ids.as_slice() {- [team_id] => Ok(*team_id),- [] => Err(DocumentError::BadRequest(- "teamId is required because the user does not belong to a team".to_string(),- )),- _ => Err(DocumentError::BadRequest(- "teamId is required because the user belongs to multiple teams".to_string(),- )),- }- }-async fn team_task_metadata_for_document(&self,document_id: &str,@@ -447,15 +415,6 @@ impl<<Self as DocumentService>::handle_task_properties(self, user_id, document_id, request).await}- async fn resolve_task_team_id(- &self,- user_id: MacroUserIdStr<'static>,- requested_team_id: Option<uuid::Uuid>,- ) -> Result<uuid::Uuid, DocumentError> {- self.resolve_task_team_id_for_user(&user_id, requested_team_id)- .await- }-#[tracing::instrument(err, skip(self))]async fn mark_document_uploaded(&self, document_id: &str) -> Result<(), DocumentError> {self.repo@@ -734,33 +693,17 @@ impl<.await}- async fn resolve_task_team_id(- &self,- user_id: MacroUserIdStr<'static>,- requested_team_id: Option<uuid::Uuid>,- ) -> Result<uuid::Uuid, DocumentError> {- self.resolve_task_team_id_for_user(&user_id, requested_team_id)- .await- }-#[tracing::instrument(err, skip(self, args))]async fn create_document(&self,user_id: MacroUserIdStr<'static>,- mut args: CreateDocumentRepoArgs,+ args: CreateDocumentRepoArgs,job_id: Option<String>,) -> Result<CreateDocumentResponseData, DocumentError> {if args.document_name.graphemes(true).count() > 100 {return Err(DocumentError::BadRequest("name too long".to_string()));}- if args.is_task {- let team_id = self- .resolve_task_team_id_for_user(&args.user_id, args.team_id)- .await?;- args.team_id = Some(team_id);- }-let file_type = args.file_type;let project_id = args.project_id;let sha = args.sha.clone();@@ -1077,7 +1020,15 @@ impl<let document_name = FileType::clean_document_name(&document_name).unwrap_or(document_name);let copy_team_id = if original_metadata.sub_type == Some(DocumentSubType::Task) {- Some(self.resolve_task_team_id_for_user(&user_id, None).await?)+ let team_id = self+ .repo+ .get_team_ids_for_user(user_id.as_ref())+ .await+ .map_err(|e| DocumentError::Internal(e.into()))?;++ let team_id = team_id.first();++ team_id.copied()} else {None};diff --git a/rust/cloud-storage/github/src/domain/service/sync/test.rs b/rust/cloud-storage/github/src/domain/service/sync/test.rsindex d32a98eab7..4ebc2851d1 100644--- a/rust/cloud-storage/github/src/domain/service/sync/test.rs+++ b/rust/cloud-storage/github/src/domain/service/sync/test.rs@@ -177,13 +177,6 @@ impl DocumentService for StubDocumentService {unimplemented!()}- async fn resolve_task_team_id(- &self,- _user_id: MacroUserIdStr<'static>,- requested_team_id: Option<uuid::Uuid>,- ) -> Result<uuid::Uuid, DocumentError> {- requested_team_id.ok_or_else(|| DocumentError::BadRequest("teamId is required".into()))- }async fn get_document_content(&self,_document_context: &DocumentBasic,