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(notif): truncate digest len (#2306)
Sean Aye167fc0ac6d81
diff --git a/rust/cloud-storage/email_formatting/src/lib.rs b/rust/cloud-storage/email_formatting/src/lib.rsindex efe2f6f01b..46e10d8d83 100644--- a/rust/cloud-storage/email_formatting/src/lib.rs+++ b/rust/cloud-storage/email_formatting/src/lib.rs@@ -14,6 +14,7 @@ use std::time::Duration;#[template(path = "digest.html")]struct DigestTemplate {notifs: Vec<NotifPreview>,+ num_truncated: usize,}struct NotifPreview {@@ -22,6 +23,8 @@ struct NotifPreview {body: String,}+const TRUNCATE_LEN: usize = 15;+impl NotifPreview {#[tracing::instrument(err)]fn new(v: UserNotificationRow<NotifEvent>) -> Result<Self, Report> {@@ -53,6 +56,8 @@ impl EmailDigestNotification {..} = digest;+ let input_len = notifications.len();+fn log_err<E: std::fmt::Debug>(e: &E) {tracing::warn!("{e:?}");}@@ -63,15 +68,21 @@ impl EmailDigestNotification {.filter_map(|res| res.inspect_err(log_err).ok()).map(NotifPreview::new).filter_map(Result::ok)+ .take(TRUNCATE_LEN).collect();- let templated_len = notifs.len();+ let preview_len = notifs.len();+ let num_truncated = input_len - preview_len;- let inner_html_string = DigestTemplate { notifs }.render()?;+ let inner_html_string = DigestTemplate {+ notifs,+ num_truncated,+ }+ .render()?;Ok(EmailDigestNotification {inner_html_string,- subject: format!("You have {} new notifications on Macro", templated_len),+ subject: format!("You have {input_len} new notifications on Macro"),})}}diff --git a/rust/cloud-storage/email_formatting/templates/digest.html b/rust/cloud-storage/email_formatting/templates/digest.htmlindex 36d18b2a4e..69fe92409f 100644--- a/rust/cloud-storage/email_formatting/templates/digest.html+++ b/rust/cloud-storage/email_formatting/templates/digest.html@@ -179,6 +179,20 @@/>{% endif %} {% endfor %}+ {% if num_truncated > 0 %}+ <div+ style="+ padding: 12px 17px;+ color: #636363;+ font-size: 14px;+ text-align: center;+ font-family: "Inter", sans-serif;+ "+ >+ and {{ num_truncated }} more notification{% if num_truncated != 1 %}s{% endif %}+ </div>+ {% endif %}+<hrstyle="border-top: 1px dashed #e0e0e0;