fix: Email content should account for untitled documents

This commit is contained in:
Tom Moor
2025-01-23 23:46:02 -05:00
parent c831c71c51
commit 5b6bebc308
6 changed files with 24 additions and 24 deletions

View File

@@ -103,7 +103,7 @@ export default class CommentCreatedEmail extends BaseEmail<
: `${commentText.slice(0, MAX_SUBJECT_CONTENT)}...`;
return `${parentComment ? "Re: " : ""}New comment on “${
document.title
document.titleWithDefault
}” - ${trimmedText}`;
}
@@ -136,7 +136,7 @@ export default class CommentCreatedEmail extends BaseEmail<
}: Props): string {
return `
${actorName} ${isReply ? "replied to a thread in" : "commented on"} "${
document.title
document.titleWithDefault
}"${collection?.name ? `in the ${collection.name} collection` : ""}.
Open Thread: ${teamUrl}${document.url}?commentId=${commentId}
@@ -164,10 +164,10 @@ Open Thread: ${teamUrl}${document.url}?commentId=${commentId}
<Header />
<Body>
<Heading>{document.title}</Heading>
<Heading>{document.titleWithDefault}</Heading>
<p>
{actorName} {isReply ? "replied to a thread in" : "commented on"}{" "}
<a href={threadLink}>{document.title}</a>{" "}
<a href={threadLink}>{document.titleWithDefault}</a>{" "}
{collection?.name ? `in the ${collection.name} collection` : ""}.
</p>
{body && (

View File

@@ -92,7 +92,7 @@ export default class CommentMentionedEmail extends BaseEmail<
}
protected subject({ document }: Props) {
return `Mentioned you in “${document.title}`;
return `Mentioned you in “${document.titleWithDefault}`;
}
protected preview({ actorName }: Props): string {
@@ -111,7 +111,7 @@ export default class CommentMentionedEmail extends BaseEmail<
collection,
}: Props): string {
return `
${actorName} mentioned you in a comment on "${document.title}"${
${actorName} mentioned you in a comment on "${document.titleWithDefault}"${
collection.name ? `in the ${collection.name} collection` : ""
}.
@@ -139,10 +139,10 @@ Open Thread: ${teamUrl}${document.url}?commentId=${commentId}
<Header />
<Body>
<Heading>{document.title}</Heading>
<Heading>{document.titleWithDefault}</Heading>
<p>
{actorName} mentioned you in a comment on{" "}
<a href={threadLink}>{document.title}</a>{" "}
<a href={threadLink}>{document.titleWithDefault}</a>{" "}
{collection.name ? `in the ${collection.name} collection` : ""}.
</p>
{body && (

View File

@@ -92,7 +92,7 @@ export default class CommentResolvedEmail extends BaseEmail<
}
protected subject({ document }: Props) {
return `Resolved a comment thread in “${document.title}`;
return `Resolved a comment thread in “${document.titleWithDefault}`;
}
protected preview({ actorName }: Props): string {
@@ -110,7 +110,7 @@ export default class CommentResolvedEmail extends BaseEmail<
commentId,
collection,
}: Props): string {
const t1 = `${actorName} resolved a comment thread on "${document.title}"`;
const t1 = `${actorName} resolved a comment thread on "${document.titleWithDefault}"`;
const t2 = collection.name ? ` in the ${collection.name} collection` : "";
const t3 = `Open Thread: ${teamUrl}${document.url}?commentId=${commentId}`;
return `${t1}${t2}.\n\n${t3}`;
@@ -136,10 +136,10 @@ export default class CommentResolvedEmail extends BaseEmail<
<Header />
<Body>
<Heading>{document.title}</Heading>
<Heading>{document.titleWithDefault}</Heading>
<p>
{actorName} resolved a comment on{" "}
<a href={threadLink}>{document.title}</a>{" "}
<a href={threadLink}>{document.titleWithDefault}</a>{" "}
{collection.name ? `in the ${collection.name} collection` : ""}.
</p>
{body && (

View File

@@ -92,7 +92,7 @@ export default class DocumentMentionedEmail extends BaseEmail<
}
protected subject({ document }: Props) {
return `Mentioned you in “${document.title}`;
return `Mentioned you in “${document.titleWithDefault}`;
}
protected preview({ actorName }: Props): string {
@@ -116,7 +116,7 @@ export default class DocumentMentionedEmail extends BaseEmail<
return `
You were mentioned
${actorName} mentioned you in the document “${document.title}”.
${actorName} mentioned you in the document “${document.titleWithDefault}”.
Open Document: ${teamUrl}${document.url}
`;
@@ -137,7 +137,7 @@ Open Document: ${teamUrl}${document.url}
<Heading>You were mentioned</Heading>
<p>
{actorName} mentioned you in the document{" "}
<a href={documentLink}>{document.title}</a>.
<a href={documentLink}>{document.titleWithDefault}</a>.
</p>
{body && (
<>

View File

@@ -114,7 +114,7 @@ export default class DocumentPublishedOrUpdatedEmail extends BaseEmail<
}
protected subject({ document, eventType }: Props) {
return `${document.title}${this.eventName(eventType)}`;
return `${document.titleWithDefault}${this.eventName(eventType)}`;
}
protected preview({ actorName, eventType }: Props): string {
@@ -144,9 +144,9 @@ export default class DocumentPublishedOrUpdatedEmail extends BaseEmail<
const eventName = this.eventName(eventType);
return `
"${document.title}" ${eventName}
"${document.titleWithDefault}" ${eventName}
${actorName} ${eventName} the document "${document.title}"${
${actorName} ${eventName} the document "${document.titleWithDefault}"${
collection?.name ? `, in the ${collection.name} collection` : ""
}.
@@ -176,11 +176,11 @@ Open Document: ${teamUrl}${document.url}
<Body>
<Heading>
{document.title} {eventName}
{document.titleWithDefault} {eventName}
</Heading>
<p>
{actorName} {eventName} the document{" "}
<a href={documentLink}>{document.title}</a>
<a href={documentLink}>{document.titleWithDefault}</a>
{collection?.name ? <>, in the {collection.name} collection</> : ""}
.
</p>

View File

@@ -53,7 +53,7 @@ export default class DocumentSharedEmail extends BaseEmail<
}
protected subject({ actorName, document }: Props) {
return `${actorName} shared “${document.title}” with you`;
return `${actorName} shared “${document.titleWithDefault}” with you`;
}
protected preview({ actorName }: Props): string {
@@ -66,7 +66,7 @@ export default class DocumentSharedEmail extends BaseEmail<
protected renderAsText({ actorName, teamUrl, document }: Props): string {
return `
${actorName} shared “${document.title}” with you.
${actorName} shared “${document.titleWithDefault}” with you.
View Document: ${teamUrl}${document.path}
`;
@@ -87,10 +87,10 @@ View Document: ${teamUrl}${document.path}
<Header />
<Body>
<Heading>{document.title}</Heading>
<Heading>{document.titleWithDefault}</Heading>
<p>
{actorName} invited you to {permission} the{" "}
<a href={documentUrl}>{document.title}</a> document.
<a href={documentUrl}>{document.titleWithDefault}</a> document.
</p>
<p>
<Button href={documentUrl}>View Document</Button>