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(notif): channel reply notif title (#3436)

Sean Aye7d641e74ecdb
diff --git a/rust/cloud-storage/model_notifications/src/metadata.rs b/rust/cloud-storage/model_notifications/src/metadata.rs
index 8f89561b5a..b92093affe 100644
--- a/rust/cloud-storage/model_notifications/src/metadata.rs
+++ b/rust/cloud-storage/model_notifications/src/metadata.rs
@@ -16,6 +16,9 @@ use serde::{Deserialize, Serialize};
use utoipa::ToSchema;
use uuid::Uuid;
+#[cfg(test)]
+mod test;
+
#[derive(Debug, Clone, ToSchema, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AiResponseMetadata {
@@ -349,12 +352,12 @@ impl NotificationTitle for MentionedInDocumentCommentMetadata {
impl NotificationTitle for ChannelReplyMetadata {
fn format_title(
&self,
- sender_id: Option<MacroUserIdStr<'_>>,
+ _sender_id: Option<MacroUserIdStr<'_>>,
) -> Result<String, rootcause::Report> {
- let sender =
- sender_id.ok_or_else(|| report!("Expected sender id to exist for {:?}", &self))?;
-
- Ok(format!("Reply from {}", sender.0.email_part().email_str()))
+ Ok(format!(
+ "Reply from {}",
+ self.user_id.email_part().local_part()
+ ))
}
fn format_body(
diff --git a/rust/cloud-storage/model_notifications/src/metadata/test.rs b/rust/cloud-storage/model_notifications/src/metadata/test.rs
new file mode 100644
index 0000000000..72f41f64f0
--- /dev/null
+++ b/rust/cloud-storage/model_notifications/src/metadata/test.rs
@@ -0,0 +1,28 @@
+use super::*;
+
+fn uid(value: &str) -> MacroUserIdStr<'static> {
+ MacroUserIdStr::parse_from_str(value).unwrap().into_owned()
+}
+
+#[test]
+fn channel_reply_title_uses_reply_sender_from_metadata() {
+ let notification = ChannelReplyMetadata {
+ thread_id: Uuid::nil().to_string(),
+ message_id: Uuid::nil().to_string(),
+ user_id: uid("macro|[email protected]"),
+ message_content: "hello".to_string(),
+ has_attachments: false,
+ thread_parent_sender_id: None,
+ common: CommonChannelMetadata {
+ channel_type: ChannelType::Team,
+ channel_name: "AI Team".to_string(),
+ },
+ sender_profile_picture_url: None,
+ };
+
+ let title = notification
+ .format_title(Some(uid("macro|[email protected]")))
+ .unwrap();
+
+ assert_eq!(title, "Reply from reply.sender");
+}