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(notifications): say "task" not "document" when a shared entity is a task (#5113)

Jacob Beckerman636837fb92e2
diff --git a/apps/web/src/features/notifications/notification-metadata.ts b/apps/web/src/features/notifications/notification-metadata.ts
index 818c8310ca..f665d84418 100644
--- a/apps/web/src/features/notifications/notification-metadata.ts
+++ b/apps/web/src/features/notifications/notification-metadata.ts
@@ -7,7 +7,17 @@ import type { UnifiedNotification } from './types';
export function getNotificationAction(n: UnifiedNotification): string {
return match(n.notification_metadata.tag)
.with('channel_mention', () => 'mentioned you in')
- .with('document_mention', () => 'sent a document')
+ .with('document_mention', () => {
+ const meta = n.notification_metadata;
+ if (
+ meta.tag === 'document_mention' &&
+ meta.content.subType?.type === 'task'
+ ) {
+ return 'sent a task';
+ }
+
+ return 'sent a document';
+ })
.with('mentioned_in_document_comment', () => 'mentioned you in')
.with('replied_to_document_comment_thread', () => 'replied in')
.with('commented_on_document', () => 'commented on')
diff --git a/crates/model_notifications/src/metadata.rs b/crates/model_notifications/src/metadata.rs
index 1367972a31..b1ba3651bb 100644
--- a/crates/model_notifications/src/metadata.rs
+++ b/crates/model_notifications/src/metadata.rs
@@ -777,7 +777,11 @@ impl NotificationTitle for DocumentMentionMetadata {
.map(|sender| sender.0.email_part().email_str().to_string())
.or_else(|| self.channel.sender_display_name.clone())
.ok_or_else(|| report!("Expected sender id to exist for {:?}", &self))?;
- Ok(format!("{sender} sent a document",))
+ let noun = match self.sub_type {
+ Some(NotificationDocumentSubType::Task) => "task",
+ _ => "document",
+ };
+ Ok(format!("{sender} sent a {noun}"))
}
fn format_body(
diff --git a/crates/model_notifications/src/metadata/test.rs b/crates/model_notifications/src/metadata/test.rs
index f866821325..0b4a912387 100644
--- a/crates/model_notifications/src/metadata/test.rs
+++ b/crates/model_notifications/src/metadata/test.rs
@@ -570,6 +570,44 @@ fn channel_mention_title_falls_back_to_bot_display_name() {
assert_eq!(title, "Helper Bot mentioned you in #general");
}
+fn document_mention(sub_type: Option<NotificationDocumentSubType>) -> DocumentMentionMetadata {
+ DocumentMentionMetadata {
+ document_name: "Q3 plan".to_string(),
+ owner: uid("macro|[email protected]"),
+ file_type: Some("md".to_string()),
+ sub_type,
+ channel: ChannelMentionMetadata {
+ message_id: Uuid::nil().to_string(),
+ message_content: "check this out".to_string(),
+ has_attachments: false,
+ thread_id: None,
+ sender_display_name: None,
+ common: CommonChannelMetadata {
+ channel_type: ChannelType::Public,
+ channel_name: "general".to_string(),
+ },
+ sender_profile_picture_url: None,
+ },
+ }
+}
+
+#[test]
+fn document_mention_title_says_task_for_task_sub_type() {
+ let task = document_mention(Some(NotificationDocumentSubType::Task));
+ let doc = document_mention(None);
+
+ assert_eq!(
+ task.format_title(Some(uid("macro|[email protected]")))
+ .unwrap(),
+ "[email protected] sent a task"
+ );
+ assert_eq!(
+ doc.format_title(Some(uid("macro|[email protected]")))
+ .unwrap(),
+ "[email protected] sent a document"
+ );
+}
+
#[test]
fn channel_message_send_legacy_json_deserializes_with_required_sender() {
let legacy: ChannelMessageSendMetadata = serde_json::from_value(serde_json::json!({