Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.
TypeScript i18nextnext-authnextjspostgresqlprismareact-emailt3-stacktailwindcsstrpcturborepotypescriptzod
✨ Include comment content in the new comment notification email (#2784)
Luke Vella39a085d577d9
diff --git a/apps/web/src/trpc/routers/polls/comments.ts b/apps/web/src/trpc/routers/polls/comments.tsindex 3730c6997..f3bff56cd 100644--- a/apps/web/src/trpc/routers/polls/comments.ts+++ b/apps/web/src/trpc/routers/polls/comments.ts@@ -161,6 +161,7 @@ export const comments = router({branding: await getInstanceBranding(),props: {authorName,+ content: newComment.content,pollUrl: absoluteUrl(`/poll/${poll.id}`),disableNotificationsUrl: absoluteUrl("/settings/notifications"),title: poll.title,diff --git a/packages/emails/locales/en/emails.json b/packages/emails/locales/en/emails.jsonindex 7a8c3bc5c..25e30fc19 100644--- a/packages/emails/locales/en/emails.json+++ b/packages/emails/locales/en/emails.json@@ -56,7 +56,7 @@"login_content2": "You're receiving this email because a request was made to login to <domain />. If this wasn't you, contact <a>{supportEmail}</a>.","newComment_content": "<b>{authorName}</b> has commented on <b>{title}</b>.","newComment_heading": "New Comment",- "newComment_preview": "Go to your poll to see what they said.",+ "newComment_replyGuidance": "Replying to this email will not reach {authorName}. To respond, add a comment on the poll.","newComment_subject": "{authorName} has commented on {title}","newParticipant_content": "<b>{name}</b> has responded to <b>{title}</b>.","newParticipant_content2": "Go to your poll to see the new response.",diff --git a/packages/emails/src/templates/new-comment.tsx b/packages/emails/src/templates/new-comment.tsxindex 5dead7159..2bfdb33e4 100644--- a/packages/emails/src/templates/new-comment.tsx+++ b/packages/emails/src/templates/new-comment.tsx@@ -7,9 +7,11 @@ import { previewChrome } from "../components/preview-chrome";import {Body,Button,+ borderColor,Container,Heading,Link,+ Section,Text,} from "../components/styled-components";import { createEmailI18n } from "../i18n";@@ -22,27 +24,31 @@ type NewCommentEmailProps = {chrome: EmailChrome;title: string;authorName: string;+ content: string;pollUrl: string;disableNotificationsUrl: string;};+const PREVIEW_LENGTH = 140;+async function NewCommentEmail({title,authorName,+ content,pollUrl,disableNotificationsUrl,locale = "en",chrome,}: NewCommentEmailProps) {const { t, i18n } = await createEmailI18n(locale);+ const previewText =+ content.length > PREVIEW_LENGTH+ ? `${content.slice(0, PREVIEW_LENGTH)}…`+ : content;return (<Html><Head />- <Preview>- {t("newComment_preview", {- defaultValue: "Go to your poll to see what they said.",- })}- </Preview>+ <Preview>{previewText}</Preview><Body><Container><Img@@ -71,6 +77,29 @@ async function NewCommentEmail({values={{ authorName, title }}/></Text>+ <Section+ style={{+ borderLeft: `3px solid ${borderColor}`,+ paddingLeft: "16px",+ }}+ >+ <Text style={{ margin: 0, fontWeight: "bold" }} small>+ {authorName}+ </Text>+ <Text style={{ margin: "8px 0 0", whiteSpace: "pre-wrap" }}>+ {content}+ </Text>+ </Section>+ <Text small light={true}>+ <Trans+ t={t}+ i18n={i18n}+ ns="emails"+ i18nKey="newComment_replyGuidance"+ defaults="Replying to this email will not reach {authorName}. To respond, add a comment on the poll."+ values={{ authorName }}+ />+ </Text><Button href={pollUrl} color={chrome.primaryColor}><Transt={t}@@ -110,6 +139,8 @@ async function NewCommentEmail({NewCommentEmail.PreviewProps = {title: "Untitled Poll",authorName: "Someone",+ content:+ "Hi everyone! I can make most of these times work, but Tuesday afternoon would be best for me.\nLooking forward to it!",pollUrl: "https://rallly.co",disableNotificationsUrl: "https://rallly.co",locale: "en",